Commit 5b311fe7 authored by Ghislain MARY's avatar Ghislain MARY

Add public APIs rtp_session_sendto() and rtp_session_recvfrom() + remove...

Add public APIs rtp_session_sendto() and rtp_session_recvfrom() + remove useless argument to the RtpTransport's close function.
parent 7c55c0b6
......@@ -115,7 +115,7 @@ typedef struct _RtpTransport
ortp_socket_t (*t_getsocket)(struct _RtpTransport *t);
int (*t_sendto)(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen);
int (*t_recvfrom)(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
void (*t_close)(struct _RtpTransport *transport, void *userData);
void (*t_close)(struct _RtpTransport *transport);
/**
* Mandatory callback responsible of freeing the #_RtpTransport object AND the pointer.
* @param[in] transport #_RtpTransport object to free.
......@@ -546,6 +546,8 @@ ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, size_t
ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, size_t payload_size, void (*freefn)(void*));
ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, size_t size, void (*freefn)(void*) );
ORTP_PUBLIC int rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t userts);
ORTP_PUBLIC int rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen);
ORTP_PUBLIC int rtp_session_recvfrom(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, struct sockaddr *from, socklen_t *fromlen);
/* high level recv and send functions */
ORTP_PUBLIC int rtp_session_recv_with_ts(RtpSession *session, uint8_t *buffer, int len, uint32_t ts, int *have_more);
ORTP_PUBLIC int rtp_session_send_with_ts(RtpSession *session, const uint8_t *buffer, int len, uint32_t userts);
......
......@@ -434,7 +434,7 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
while((om=getq(&session->net_sim_ctx->send_q))!=NULL){
count++;
ortp_mutex_unlock(&session->net_sim_ctx->mutex);
is_rtp_packet=om->reserved1; /*it was set by _rtp_session_sendto()*/
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(rtp_session_get_socket(session, is_rtp_packet), om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
......@@ -472,7 +472,7 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
todrop = om; /*simulate a packet loss*/
}else if (ortp_timespec_compare(&packet_time, &current) <= 0){
/*it is time to send this packet*/
is_rtp_packet=om->reserved1; /*it was set by _rtp_session_sendto()*/
is_rtp_packet=om->reserved1; /*it was set by rtp_session_sendto()*/
_ortp_sendto(is_rtp_packet ? session->rtp.gs.socket : session->rtcp.gs.socket, om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
todrop = om;
}else {
......
......@@ -1422,7 +1422,7 @@ void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports
if (release_transports){
if (session->rtp.gs.tr) {
if (session->rtp.gs.tr->t_close)
session->rtp.gs.tr->t_close(session->rtp.gs.tr, session->rtp.gs.tr->data);
session->rtp.gs.tr->t_close(session->rtp.gs.tr);
session->rtp.gs.tr->t_destroy(session->rtp.gs.tr);
}
......@@ -1430,7 +1430,7 @@ void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports
if (session->rtcp.gs.tr) {
if (session->rtcp.gs.tr->t_close)
session->rtcp.gs.tr->t_close(session->rtcp.gs.tr, session->rtcp.gs.tr->data);
session->rtcp.gs.tr->t_close(session->rtcp.gs.tr);
session->rtcp.gs.tr->t_destroy(session->rtcp.gs.tr);
}
session->rtcp.gs.tr = 0;
......@@ -2085,7 +2085,7 @@ int meta_rtp_transport_sendto(RtpTransport *t, mblk_t *msg , int flags, const st
if (m->endpoint!=NULL){
ret=m->endpoint->t_sendto(m->endpoint,msg,flags,to,tolen);
}else{
ret=_rtp_session_sendto(t->session, m->is_rtp,msg,flags,to,tolen);
ret=rtp_session_sendto(t->session, m->is_rtp,msg,flags,to,tolen);
}
return ret;
}
......@@ -2151,7 +2151,7 @@ int meta_rtp_transport_modifier_inject_packet_to_send_to(const RtpTransport *t,
if (m->endpoint != NULL) {
ret = m->endpoint->t_sendto(m->endpoint, msg, flags, to, tolen);
} else {
ret = _rtp_session_sendto(t->session, m->is_rtp, msg, flags, to, tolen);
ret = rtp_session_sendto(t->session, m->is_rtp, msg, flags, to, tolen);
}
update_sent_bytes(&t->session->rtp.gs, ret);
return ret;
......@@ -2254,10 +2254,10 @@ int meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct
return ret;
}
void meta_rtp_transport_close(RtpTransport *t, void *user_data) {
MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)user_data;
void meta_rtp_transport_close(RtpTransport *t) {
MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
if (m->endpoint!=NULL){
m->endpoint->t_close(m->endpoint,m->endpoint->data);
m->endpoint->t_close(m->endpoint);
}
}
......
......@@ -1066,7 +1066,7 @@ int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockad
return error;
}
int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
int rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
int ret;
_rtp_session_check_socket_refresh(session);
......@@ -1088,6 +1088,10 @@ int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags
return ret;
}
int rtp_session_recvfrom(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, struct sockaddr *from, socklen_t *fromlen) {
return rtp_session_rtp_recv_abstract(is_rtp ? session->rtp.gs.socket : session->rtcp.gs.socket, m, flags, from, fromlen);
}
void update_sent_bytes(OrtpStream *os, int nbytes) {
int overhead = ortp_stream_is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
if ((os->sent_bytes == 0) && (os->send_bw_start.tv_sec == 0) && (os->send_bw_start.tv_usec == 0)) {
......@@ -1119,7 +1123,7 @@ static int rtp_session_rtp_sendto(RtpSession * session, mblk_t * m, struct socka
if (rtp_session_using_transport(session, rtp)){
error = (session->rtp.gs.tr->t_sendto) (session->rtp.gs.tr,m,0,destaddr,destlen);
}else{
error=_rtp_session_sendto(session, TRUE,m,0,destaddr,destlen);
error=rtp_session_sendto(session, TRUE,m,0,destaddr,destlen);
}
if (!is_aux){
/*errors to auxiliary destinations are not notified*/
......
......@@ -89,7 +89,6 @@ uint64_t ortp_timeval_to_ntp(const struct timeval *tv);
bool_t ortp_stream_is_ipv6(OrtpStream *os);
int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen);
int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen);
void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports);
#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