Commit cb4f9f5c authored by Simon Morlat's avatar Simon Morlat

implement rtcp_mux

parent 055c29e5
......@@ -112,6 +112,7 @@ extern "C"{
ORTP_PUBLIC void rtp_add_csrc(mblk_t *mp ,uint32_t csrc);
#define rtp_set_payload_type(mp,pt) ((rtp_header_t*)((mp)->b_rptr))->paytype=(pt)
#define rtp_get_version(mp) (((rtp_header_t*)((mp)->b_rptr))->version)
#define rtp_get_markbit(mp) (((rtp_header_t*)((mp)->b_rptr))->markbit)
#define rtp_get_extbit(mp) (((rtp_header_t*)((mp)->b_rptr))->extbit)
#define rtp_get_timestamp(mp) (((rtp_header_t*)((mp)->b_rptr))->timestamp)
......
......@@ -408,6 +408,7 @@ struct _RtpSession
bool_t use_connect; /* use connect() on the socket */
bool_t ssrc_set;
bool_t reuseaddr; /*setsockopt SO_REUSEADDR */
bool_t rtcp_mux;
unsigned char avpf_features; /**< A bitmask of ORTP_AVPF_FEATURE_* macros. */
};
......@@ -509,6 +510,10 @@ ORTP_PUBLIC void rtp_session_set_symmetric_rtp (RtpSession * session, bool_t yes
ORTP_PUBLIC bool_t rtp_session_get_symmetric_rtp (const RtpSession * session);
ORTP_PUBLIC void rtp_session_enable_rtcp_mux(RtpSession *session, bool_t yesno);
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);
......
......@@ -388,7 +388,7 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
is_rtp_packet=om->reserved1; /*it was set by _rtp_session_sendto()*/
om=rtp_session_network_simulate(session,om, &is_rtp_packet);
if (om){
_ortp_sendto(is_rtp_packet ? session->rtp.gs.socket : session->rtcp.gs.socket, om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
_ortp_sendto(rtp_session_get_socket(session, is_rtp_packet), om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
freemsg(om);
}
ortp_mutex_lock(&session->net_sim_ctx->mutex);
......@@ -399,7 +399,7 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
is_rtp_packet=TRUE;
om=rtp_session_network_simulate(session,NULL, &is_rtp_packet);
if (om){
_ortp_sendto(is_rtp_packet ? session->rtp.gs.socket : session->rtcp.gs.socket, om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
_ortp_sendto(rtp_session_get_socket(session, is_rtp_packet), om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
freemsg(om);
}
}
......
......@@ -1739,6 +1739,14 @@ rtp_session_set_symmetric_rtp (RtpSession * session, bool_t yesno)
session->symmetric_rtp =yesno;
}
void rtp_session_enable_rtcp_mux(RtpSession *session, bool_t yesno){
session->rtcp_mux = yesno;
}
bool_t rtp_session_rtcp_mux_enabled(RtpSession *session){
return session->rtcp_mux;
}
/**
* If yesno is TRUE, thus a connect() syscall is done on the socket to
* the destination address set by rtp_session_set_remote_addr(), or
......
......@@ -1052,6 +1052,14 @@ static int rtp_sendmsg(int sock,mblk_t *m, const struct sockaddr *rem_addr, sock
}
#endif
ortp_socket_t rtp_session_get_socket(RtpSession *session, bool_t is_rtp){
if (session->rtcp_mux){
return session->rtp.gs.socket;
}else{
return is_rtp ? session->rtp.gs.socket : session->rtcp.gs.socket;
}
}
int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
int error;
#ifdef USE_SENDMSG
......@@ -1080,7 +1088,7 @@ int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags
putq(&session->net_sim_ctx->send_q, m);
ortp_mutex_unlock(&session->net_sim_ctx->mutex);
}else{
ortp_socket_t sockfd=is_rtp ? session->rtp.gs.socket : session->rtcp.gs.socket;
ortp_socket_t sockfd = rtp_session_get_socket(session, is_rtp);
ret=_ortp_sendto(sockfd, m, flags, destaddr, destlen);
}
return ret;
......@@ -1169,8 +1177,8 @@ int rtp_session_rtp_send (RtpSession * session, mblk_t * m){
static int rtp_session_rtcp_sendto(RtpSession * session, mblk_t * m, struct sockaddr *destaddr, socklen_t destlen, bool_t is_aux){
int error=0;
ortp_socket_t sockfd=session->rtcp.gs.socket;
ortp_socket_t sockfd = rtp_session_get_socket(session, FALSE);
if (rtp_session_using_transport(session, rtcp)){
error = (session->rtcp.gs.tr->t_sendto) (session->rtcp.gs.tr, m, 0,
destaddr, destlen);
......@@ -1523,6 +1531,17 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
}
remaddr = (struct sockaddr *)&mp->net_addr;
addrlen = mp->net_addrlen;
/*in case of rtcp-mux, we are allowed to reconsider whether it is an RTP or RTCP packet*/
if (session->rtcp_mux && is_rtp_packet){
if (rtp_get_version(mp) == 2){
int pt = rtp_get_payload_type(mp);
if (pt >= 64 && pt <= 95){
/*this is assumed to be an RTCP packet*/
is_rtp_packet = FALSE;
}
}
}
if (is_rtp_packet){
if (session->use_connect){
......
......@@ -88,4 +88,6 @@ void rtp_session_set_transports(RtpSession *session, RtpTransport *rtptr, RtpTra
ORTP_PUBLIC bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt);
ortp_socket_t rtp_session_get_socket(RtpSession *session, bool_t is_rtp);
#endif
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