Commit 35b2e735 authored by jehan's avatar jehan

rework symmetric rtp to centralize most of decision in a single function:...

rework symmetric rtp to centralize most of decision in a single function: rtp_session_update_remote_sock_addr
parent 3c0e10e3
......@@ -357,6 +357,9 @@ ORTP_PUBLIC int ortp_pipe_write(ortp_pipe_t p, const uint8_t *buf, int len);
ORTP_PUBLIC void *ortp_shm_open(unsigned int keyid, int size, int create);
ORTP_PUBLIC void ortp_shm_close(void *memory);
ORTP_PUBLIC bool_t ortp_is_multicast_addr(const struct sockaddr *addr);
#endif
#ifdef __cplusplus
......
......@@ -548,12 +548,12 @@ ORTP_PUBLIC void ortp_loss_rate_estimator_init(OrtpLossRateEstimator *obj, int m
* cumulative loss factor which allows us to take into consideration duplicates
* packets as well.
* @param[in] obj #OrtpLossRateEstimator object.
* @param[in] stream #_RtpStream stream in which the report block to consider belongs.
* @param[in] stream #_RtpSession stream in which the report block to consider belongs.
* @param[in] rb Report block to analyze.
* @return TRUE if a new loss rate estimation is ready, FALSE otherwise.
*/
ORTP_PUBLIC bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
const struct _RtpStream *stream,
const struct _RtpSession *session,
const report_block_t *rb);
/**
* Get the latest loss rate in percentage estimation computed.
......
......@@ -74,8 +74,10 @@ typedef struct rtp_stats
uint64_t bad; /* incoming packets that did not appear to be RTP */
uint64_t discarded; /* incoming packets discarded because the queue exceeds its max size */
uint64_t sent_rtcp_packets; /* outgoing RTCP packets counter (only packets that embed a report block are considered) */
uint64_t recv_rtcp_packets; /* incoming RTCP packets counter (only packets that embed a report block are considered) */
} rtp_stats_t;
typedef struct jitter_stats
{
uint32_t jitter; /* interarrival jitter at last emitted sender report */
......
......@@ -320,7 +320,6 @@ typedef struct _RtpStream
uint16_t snd_seq; /* send sequence number */
uint32_t last_rtcp_packet_count; /*the sender's octet count in the last sent RTCP SR*/
uint32_t sent_payload_bytes; /*used for RTCP sender reports*/
rtp_stats_t stats;
int recv_errno;
int send_errno;
int snd_socket_size;
......@@ -411,6 +410,7 @@ struct _RtpSession
bool_t reuseaddr; /*setsockopt SO_REUSEADDR */
bool_t rtcp_mux;
unsigned char avpf_features; /**< A bitmask of ORTP_AVPF_FEATURE_* macros. */
rtp_stats_t stats;
};
......@@ -518,6 +518,11 @@ ORTP_PUBLIC bool_t rtp_session_rtcp_mux_enabled(RtpSession *session);
ORTP_PUBLIC void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno);
ORTP_PUBLIC void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno);
/*
* rtcp status
* @return TRUE if rtcp is enabled for this session
*/
ORTP_PUBLIC bool_t rtp_session_rtcp_enabled(const RtpSession *session);
ORTP_PUBLIC void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms);
......@@ -555,6 +560,17 @@ ORTP_PUBLIC float rtp_session_get_rtcp_send_bandwidth(RtpSession *session);
ORTP_PUBLIC float rtp_session_get_rtcp_recv_bandwidth(RtpSession *session);
ORTP_PUBLIC void rtp_session_send_rtcp_APP(RtpSession *session, uint8_t subtype, const char *name, const uint8_t *data, int datalen);
/**
* Send the rtcp datagram \a packet to the destination set by rtp_session_set_remote_addr()
* The packet (\a packet) is freed once it is sent.
*
* @param session a rtp session.
* @param packet a rtcp packet presented as a mblk_t.
* @return the number of bytes sent over the network.
**/
ORTP_PUBLIC int rtp_session_rtcp_sendm_raw(RtpSession * session, mblk_t * m);
ORTP_PUBLIC uint32_t rtp_session_get_current_send_ts(RtpSession *session);
ORTP_PUBLIC uint32_t rtp_session_get_current_recv_ts(RtpSession *session);
......@@ -669,6 +685,20 @@ ORTP_PUBLIC void meta_rtp_transport_set_endpoint(RtpTransport *transport,RtpTran
ORTP_PUBLIC void meta_rtp_transport_destroy(RtpTransport *tp);
ORTP_PUBLIC void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *tpm);
/*
* Update remote addr is the following case:
* rtp symetric == TRUE && socket not connected && remote addr has changed && ((rtp/rtcp packet && not onlyat start) or (no rtp/rtcp packets received))
* @param[in] session on which to perform change
* @param[in] mp packet where remote addr is retreived
* @param[in] is_rtp true if rtp
* @param[in] only_at_start only perform changes if no valid packets received yet
* @return 0 if chaged was performed
*
*/
ORTP_PUBLIC int rtp_session_update_remote_sock_addr(RtpSession * session, mblk_t * mp, bool_t is_rtp,bool_t only_at_start);
#ifdef __cplusplus
}
#endif
......
......@@ -167,6 +167,8 @@ void rtp_stats_display(const rtp_stats_t *stats, const char *header) {
ortp_log(ORTP_MESSAGE, "incoming received too late %10"PRId64" packets", stats->outoftime);
ortp_log(ORTP_MESSAGE, "incoming bad formatted %10"PRId64" packets", stats->bad);
ortp_log(ORTP_MESSAGE, "incoming discarded (queue overflow) %10"PRId64" packets", stats->discarded);
ortp_log(ORTP_MESSAGE, "sent rtcp %10"PRId64" packets", stats->sent_rtcp_packets);
ortp_log(ORTP_MESSAGE, "received rtcp %10"PRId64" packets", stats->recv_rtcp_packets);
ortp_log(ORTP_MESSAGE, "===========================================================");
}
......
......@@ -897,4 +897,15 @@ unsigned int ortp_random(void){
return (unsigned int) random();
#endif
}
bool_t ortp_is_multicast_addr(const struct sockaddr *addr) {
switch (addr->sa_family) {
case AF_INET:
return IN_MULTICAST(ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr));
case AF_INET6:
return IN6_IS_ADDR_MULTICAST(&(((struct sockaddr_in6 *) addr)->sin6_addr));
default:
return FALSE;
}
}
......@@ -221,9 +221,9 @@ static void sender_info_init(sender_info_t *info, RtpSession *session){
info->ntp_timestamp_msw=htonl(ntp >>32);
info->ntp_timestamp_lsw=htonl(ntp & 0xFFFFFFFF);
info->rtp_timestamp=htonl(session->rtp.snd_last_ts);
info->senders_packet_count=(uint32_t) htonl((u_long) session->rtp.stats.packet_sent);
info->senders_packet_count=(uint32_t) htonl((u_long) session->stats.packet_sent);
info->senders_octet_count=(uint32_t) htonl((u_long) session->rtp.sent_payload_bytes);
session->rtp.last_rtcp_packet_count=session->rtp.stats.packet_sent;
session->rtp.last_rtcp_packet_count=session->stats.packet_sent;
}
static void report_block_init(report_block_t *b, RtpSession *session){
......@@ -242,11 +242,11 @@ static void report_block_init(report_block_t *b, RtpSession *session){
packet_loss = session->lost_packets_test_vector;
/* The test value is the definite cumulative one, no need to increment
it each time a packet is sent */
stream->stats.cum_packet_loss = packet_loss;
session->stats.cum_packet_loss = packet_loss;
}else {
/* Normal mode */
packet_loss = expected_packets - stream->hwrcv_since_last_SR;
stream->stats.cum_packet_loss += packet_loss;
session->stats.cum_packet_loss += packet_loss;
}
if (expected_packets>0){/*prevent division by zero and negative loss fraction*/
loss_fraction=(int)( 256 * packet_loss) / expected_packets;
......@@ -287,7 +287,7 @@ static void report_block_init(report_block_t *b, RtpSession *session){
b->ssrc=htonl(session->rcv.ssrc);
report_block_set_cum_packet_lost(b, stream->stats.cum_packet_loss);
report_block_set_cum_packet_lost(b, session->stats.cum_packet_loss);
report_block_set_fraction_lost(b, loss_fraction);
if ( session->flags & RTCP_OVERRIDE_JITTER ) {
......@@ -322,7 +322,7 @@ static void report_block_init(report_block_t *b, RtpSession *session){
static void extended_statistics( RtpSession *session, report_block_t * rb ) {
/* the jitter raw value is kept in stream clock units */
uint32_t jitter = session->rtp.jittctl.inter_jitter;
session->rtp.stats.sent_rtcp_packets ++;
session->stats.sent_rtcp_packets ++;
session->rtp.jitter_stats.sum_jitter += jitter;
session->rtp.jitter_stats.jitter=jitter;
/* stores the biggest jitter for that session and its date (in millisecond) since Epoch */
......@@ -340,7 +340,7 @@ static void extended_statistics( RtpSession *session, report_block_t * rb ) {
static int rtcp_sr_init(RtpSession *session, uint8_t *buf, int size){
rtcp_sr_t *sr=(rtcp_sr_t*)buf;
int rr=(session->rtp.stats.packet_recv>0);
int rr=(session->stats.packet_recv>0);
int sr_size=sizeof(rtcp_sr_t)-sizeof(report_block_t)+(rr*sizeof(report_block_t));
if (size<sr_size) return 0;
rtcp_common_header_init(&sr->ch,session,RTCP_SR,rr,sr_size);
......@@ -447,11 +447,11 @@ static void rtp_session_create_and_send_rtcp_packet(RtpSession *session, bool_t
mblk_t *m=NULL;
bool_t is_sr = FALSE;
if (session->rtp.last_rtcp_packet_count < session->rtp.stats.packet_sent) {
if (session->rtp.last_rtcp_packet_count < session->stats.packet_sent) {
m = make_sr(session);
session->rtp.last_rtcp_packet_count = session->rtp.stats.packet_sent;
session->rtp.last_rtcp_packet_count = session->stats.packet_sent;
is_sr = TRUE;
} else if (session->rtp.stats.packet_recv > 0) {
} else if (session->stats.packet_recv > 0) {
/* Don't send RR when no packet are received yet */
m = make_rr(session);
is_sr = FALSE;
......@@ -645,7 +645,7 @@ int rtp_session_bye(RtpSession *session, const char *reason) {
bye = rtcp_create_simple_bye_packet(session->snd.ssrc, reason);
/* SR or RR is determined by the fact whether stream was sent*/
if (session->rtp.stats.packet_sent>0)
if (session->stats.packet_sent>0)
{
cm = allocb(sizeof(rtcp_sr_t), 0);
cm->b_wptr += rtcp_sr_init(session,cm->b_wptr, sizeof(rtcp_sr_t));
......@@ -653,7 +653,7 @@ int rtp_session_bye(RtpSession *session, const char *reason) {
sdes = rtp_session_create_rtcp_sdes_packet(session, TRUE);
/* link them */
concatb(concatb(cm, sdes), bye);
} else if (session->rtp.stats.packet_recv>0){
} else if (session->stats.packet_recv>0){
/* make a RR packet */
cm = allocb(sizeof(rtcp_rr_t), 0);
cm->b_wptr += rtcp_rr_init(session, cm->b_wptr, sizeof(rtcp_rr_t));
......@@ -678,17 +678,17 @@ void ortp_loss_rate_estimator_init(OrtpLossRateEstimator *obj, int min_packet_co
obj->min_packet_count_interval=min_packet_count_interval;
obj->last_ext_seq=rtp_session_get_seq_number(session);
obj->last_cum_loss=rtp_session_get_cum_loss(session);
obj->last_packet_sent_count=session->rtp.stats.packet_sent;
obj->last_dup_packet_sent_count=session->rtp.stats.packet_dup_sent;
obj->last_packet_sent_count=session->stats.packet_sent;
obj->last_dup_packet_sent_count=session->stats.packet_dup_sent;
obj->min_time_ms_interval=min_time_ms_interval;
obj->last_estimate_time_ms=(uint64_t)-1;
}
bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj, const RtpStream *stream, const report_block_t *rb){
bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj, const RtpSession *session, const report_block_t *rb){
int32_t cum_loss=report_block_get_cum_packet_lost(rb);
int32_t extseq=report_block_get_high_ext_seq(rb);
int32_t diff_unique_outgoing=stream->stats.packet_sent-obj->last_packet_sent_count;
int32_t diff_total_outgoing=diff_unique_outgoing+stream->stats.packet_dup_sent-obj->last_dup_packet_sent_count;
int32_t diff_unique_outgoing=session->stats.packet_sent-obj->last_packet_sent_count;
int32_t diff_total_outgoing=diff_unique_outgoing+session->stats.packet_dup_sent-obj->last_dup_packet_sent_count;
int32_t diff;
uint64_t curtime;
bool_t got_value=FALSE;
......@@ -706,8 +706,8 @@ bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
ortp_warning("ortp_loss_rate_estimator_process %p: Suspected discontinuity in sequence numbering from %d to %d.", obj, obj->last_ext_seq, extseq);
obj->last_ext_seq=extseq;
obj->last_cum_loss=cum_loss;
obj->last_packet_sent_count=stream->stats.packet_sent;
obj->last_dup_packet_sent_count=stream->stats.packet_dup_sent;
obj->last_packet_sent_count=session->stats.packet_sent;
obj->last_dup_packet_sent_count=session->stats.packet_dup_sent;
}else if (diff>obj->min_packet_count_interval && curtime-obj->last_estimate_time_ms>=obj->min_time_ms_interval){
/*we have sufficient interval*/
int32_t new_losses=cum_loss-obj->last_cum_loss;
......@@ -725,8 +725,8 @@ bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
}
obj->last_ext_seq=extseq;
obj->last_cum_loss=cum_loss;
obj->last_packet_sent_count=stream->stats.packet_sent;
obj->last_dup_packet_sent_count=stream->stats.packet_dup_sent;
obj->last_packet_sent_count=session->stats.packet_sent;
obj->last_dup_packet_sent_count=session->stats.packet_dup_sent;
}
return got_value;
......
......@@ -51,7 +51,7 @@ const rtcp_common_header_t * rtcp_get_common_header(const mblk_t *m){
return NULL;
}
if (size<sizeof(rtcp_common_header_t)){
ortp_warning("Bad RTCP packet, too short.");
ortp_warning("Bad RTCP packet, too short [%i b]. on block [%p]",(int)size,m);
return NULL;
}
ch=(rtcp_common_header_t*)m->b_rptr;
......
......@@ -130,13 +130,13 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
rtp_header_t *rtp;
int msgsize;
RtpStream *rtpstream=&session->rtp;
rtp_stats_t *stats=&rtpstream->stats;
rtp_stats_t *stats=&session->stats;
msgsize=(int)(mp->b_wptr-mp->b_rptr);
if (msgsize<RTP_FIXED_HEADER_SIZE){
ortp_warning("Packet too small to be a rtp packet (%i)!",msgsize);
rtpstream->stats.bad++;
session->stats.bad++;
ortp_global_stats.bad++;
freemsg(mp);
return;
......@@ -209,13 +209,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
}
if (session->inc_same_ssrc_count>=session->rtp.ssrc_changed_thres){
/* store the sender rtp address to do symmetric RTP */
if (!session->use_connect){
if (session->rtp.gs.socket>0 && session->symmetric_rtp){
/* store the sender rtp address to do symmetric RTP */
memcpy(&session->rtp.gs.rem_addr,addr,addrlen);
session->rtp.gs.rem_addrlen=addrlen;
}
}
rtp_session_update_remote_sock_addr(session,mp,TRUE,FALSE);
session->rtp.rcv_last_ts = rtp->timestamp;
session->rcv.ssrc=rtp->ssrc;
rtp_signal_table_emit(&session->on_ssrc_changed);
......@@ -235,14 +229,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
}else{
session->ssrc_set=TRUE;
session->rcv.ssrc=rtp->ssrc;
if (!session->use_connect){
if (session->rtp.gs.socket>0 && session->symmetric_rtp){
/* store the sender rtp address to do symmetric RTP */
memcpy(&session->rtp.gs.rem_addr,addr,addrlen);
session->rtp.gs.rem_addrlen=addrlen;
}
}
rtp_session_update_remote_sock_addr(session,mp,TRUE,FALSE);
}
/* update some statistics */
......
......@@ -417,6 +417,10 @@ void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno){
session->rtcp.enabled=yesno;
}
bool_t rtp_session_rtcp_enabled(const RtpSession *session) {
return session->rtcp.enabled;
}
/**
* Sets the default interval in milliseconds for RTCP reports emitted by the session
*
......@@ -961,12 +965,12 @@ __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_t
stream->sent_payload_bytes+=(uint32_t)(packsize-RTP_FIXED_HEADER_SIZE);
ortp_global_stats.sent += (1+(int)session->duplication_left) * packsize;
stream->stats.sent += (1+(int)session->duplication_left) * packsize;
session->stats.sent += (1+(int)session->duplication_left) * packsize;
ortp_global_stats.packet_sent++;
stream->stats.packet_sent++;
session->stats.packet_sent++;
stream->stats.packet_dup_sent+=(int)session->duplication_left;
session->stats.packet_dup_sent+=(int)session->duplication_left;
ortp_global_stats.packet_sent+=(int)session->duplication_left;;
}
......@@ -1122,7 +1126,6 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
uint32_t ts;
uint32_t packet_time;
RtpScheduler *sched=session->sched;
RtpStream *stream=&session->rtp;
int rejected=0;
bool_t read_socket=TRUE;
......@@ -1158,7 +1161,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
if (mp!=NULL){
size_t msgsize=msgdsize(mp);
ortp_global_stats.recv += msgsize;
stream->stats.recv += msgsize;
session->stats.recv += msgsize;
rtp_signal_table_emit2(&session->on_telephone_event_packet,mp);
rtp_session_check_telephone_events(session,mp);
freemsg(mp);
......@@ -1195,7 +1198,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
}
}else mp=getq(&session->rtp.rq);/*no jitter buffer at all*/
stream->stats.outoftime+=rejected;
session->stats.outoftime+=rejected;
ortp_global_stats.outoftime+=rejected;
session->rtcp_xr_stats.discarded_count += rejected;
......@@ -1207,7 +1210,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
size_t msgsize = msgdsize(mp); /* evaluate how much bytes (including header) is received by app */
uint32_t packet_ts;
ortp_global_stats.recv += msgsize;
stream->stats.recv += msgsize;
session->stats.recv += msgsize;
rtp = (rtp_header_t *) mp->b_rptr;
packet_ts=rtp->timestamp;
ortp_debug("Returning mp with ts=%i", packet_ts);
......@@ -1632,7 +1635,7 @@ void rtp_session_reset (RtpSession * session)
session->rtp.sent_payload_bytes=0;
rtp_session_clear_send_error_code(session);
rtp_session_clear_recv_error_code(session);
rtp_stats_reset(&session->rtp.stats);
rtp_stats_reset(&session->stats);
rtp_session_resync(session);
session->ssrc_set=FALSE;
}
......@@ -1641,7 +1644,7 @@ void rtp_session_reset (RtpSession * session)
* Retrieve the session's statistics.
**/
const rtp_stats_t * rtp_session_get_stats(const RtpSession *session){
return &session->rtp.stats;
return &session->stats;
}
/**
......@@ -1702,7 +1705,7 @@ void rtp_session_rtcp_set_delay_value( struct _RtpSession *s, const unsigned int
}
void rtp_session_reset_stats(RtpSession *session){
memset(&session->rtp.stats,0,sizeof(rtp_stats_t));
memset(&session->stats,0,sizeof(rtp_stats_t));
}
/**
......
......@@ -1543,15 +1543,16 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
}
}
}
/* store the sender RTP address to do symmetric RTP at start mainly for stun packets.
* --For rtp packet symmetric RTP is handled in rtp_session_rtp_parse() after first valid rtp packet received.
* --For rtcp, only swicth if valid rtcp packet && first rtcp packet received*/
rtp_session_update_remote_sock_addr(session,mp,is_rtp_packet,is_rtp_packet || (rtp_get_version(mp) != 2));
if (is_rtp_packet){
if (session->use_connect){
/* In the case where use_connect is false, symmetric RTP is handled in rtp_session_rtp_parse() */
if (session->symmetric_rtp && !sock_connected){
/* store the sender RTP address to do symmetric RTP */
memcpy(&session->rtp.gs.rem_addr,&remaddr,addrlen);
session->rtp.gs.rem_addrlen=addrlen;
if (try_connect(session->rtp.gs.socket,remaddr,addrlen))
if (session->use_connect && session->symmetric_rtp && !sock_connected ){
/* In the case where use_connect is false, */
if (try_connect(session->rtp.gs.socket,remaddr,addrlen)) {
session->flags|=RTP_SOCKET_CONNECTED;
}
}
......@@ -1560,16 +1561,13 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
rtp_session_rtp_parse(session, mp, user_ts, remaddr,addrlen);
/*for bandwidth measurements:*/
}else {
if (session->symmetric_rtp && !sock_connected){
/* store the sender RTP address to do symmetric RTP */
memcpy(&session->rtcp.gs.rem_addr,remaddr,addrlen);
session->rtcp.gs.rem_addrlen=addrlen;
if (session->use_connect){
if (try_connect(session->rtcp.gs.socket,remaddr,addrlen))
if (session->use_connect && session->symmetric_rtp && !sock_connected){
if (try_connect(session->rtcp.gs.socket,remaddr,addrlen)) {
session->flags|=RTCP_SOCKET_CONNECTED;
}
}
if (process_rtcp_packet(session, mp, remaddr, addrlen) >= 0){
session->stats.recv_rtcp_packets++;
/* a copy is needed since rtp_session_notify_inc_rtcp will free the mp,
and we don't want to send RTCP XR packet before notifying the application
that a message has been received*/
......@@ -1715,3 +1713,55 @@ int rtp_session_rtcp_recv (RtpSession * session) {
}
return error;
}
int rtp_session_update_remote_sock_addr(RtpSession * session, mblk_t * mp, bool_t is_rtp,bool_t only_at_start) {
struct sockaddr_storage * rem_addr = NULL;
socklen_t rem_addrlen;
const char* socket_type;
bool_t sock_connected;
bool_t do_address_change = /*(rtp_get_version(mp) == 2 && */ !only_at_start;
if (!rtp_session_get_symmetric_rtp(session))
return -1; /*nothing to try if not rtp symetric*/
if (is_rtp) {
rem_addr = &session->rtp.gs.rem_addr;
rem_addrlen = session->rtp.gs.rem_addrlen;
socket_type = "rtp";
sock_connected = session->flags & RTP_SOCKET_CONNECTED;
do_address_change = session->rtp.gs.socket != (ortp_socket_t)-1 && ( do_address_change || rtp_session_get_stats(session)->packet_recv == 0);
} else {
rem_addr = &session->rtcp.gs.rem_addr;
rem_addrlen = session->rtcp.gs.rem_addrlen;
sock_connected = session->flags & RTCP_SOCKET_CONNECTED;
socket_type = "rtcp";
do_address_change = session->rtcp.gs.socket != (ortp_socket_t)-1 && (do_address_change || rtp_session_get_stats(session)->recv_rtcp_packets == 0);
}
if (do_address_change
&& rem_addr
&& !sock_connected
&& !ortp_is_multicast_addr((const struct sockaddr*)rem_addr)
&& memcmp(rem_addr,&mp->net_addr,mp->net_addrlen) !=0) {
char current_host[65]={0};
char current_port[12]={0};
char new_host[65]={0};
char new_port[12]={0};
getnameinfo((const struct sockaddr *)rem_addr,rem_addrlen,current_host,sizeof(current_host)-1,current_port,sizeof(current_port)-1,NI_NUMERICHOST|NI_NUMERICSERV);
getnameinfo((const struct sockaddr *)&mp->net_addr,mp->net_addrlen,new_host,sizeof(new_host)-1,new_port,sizeof(new_port)-1,NI_NUMERICHOST|NI_NUMERICSERV);
ortp_message("Switching %s destination from [%s:%s] to [%s:%s] for session [%p]"
, socket_type
, current_host
, current_port
, new_host
, new_port
, session);
memcpy(rem_addr,&mp->net_addr,mp->net_addrlen);
return 0;
}
return -1;
}
\ No newline at end of file
......@@ -57,7 +57,8 @@ mblk_t * rtp_getq(queue_t *q, uint32_t ts, int *rejected);
int rtp_session_rtp_recv(RtpSession * session, uint32_t ts);
int rtp_session_rtcp_recv(RtpSession * session);
int rtp_session_rtp_send (RtpSession * session, mblk_t * m);
int rtp_session_rtcp_send (RtpSession * session, mblk_t * m);
#define rtp_session_rtcp_send rtp_session_rtcp_sendm_raw
void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_ts, struct sockaddr *addr, socklen_t addrlen);
......
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