Commit 3af8aa68 authored by Simon Morlat's avatar Simon Morlat

allow to set rtcp interval

parent 6e9ac1d1
......@@ -23,7 +23,7 @@
#include <ortp/port.h>
#define RTCP_MAX_RECV_BUFSIZE 1024
#define RTCP_MAX_RECV_BUFSIZE 1500
#define RTCP_SENDER_INFO_SIZE 20
#define RTCP_REPORT_BLOCK_SIZE 24
......@@ -201,7 +201,7 @@ void rtp_session_rtcp_process_send(struct _RtpSession *s);
void rtp_session_rtcp_process_recv(struct _RtpSession *s);
#define RTCP_DEFAULT_REPORT_INTERVAL 5
#define RTCP_DEFAULT_REPORT_INTERVAL 5000 /*ms*/
/* packet parsing api */
......
......@@ -114,7 +114,7 @@ typedef struct _RtpStream
struct sockaddr_in rem_addr;
#endif
int rem_addrlen;
void *QoSHandle;
void *QoSHandle;
unsigned long QoSFlowID;
JitterControl jittctl;
uint32_t snd_time_offset;/*the scheduler time when the application send its first timestamp*/
......@@ -133,9 +133,6 @@ typedef struct _RtpStream
uint32_t last_rcv_SR_ts; /* NTP timestamp (middle 32 bits) of last received SR */
struct timeval last_rcv_SR_time; /* time at which last SR was received */
uint16_t snd_seq; /* send sequence number */
uint32_t last_rtcp_report_snt_r; /* the time of the last rtcp report sent, in recv timestamp unit */
uint32_t last_rtcp_report_snt_s; /* the time of the last rtcp report sent, in send timestamp unit */
uint32_t rtcp_report_snt_interval; /* the interval in timestamp unit between rtcp report sent */
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*/
unsigned int sent_bytes; /* used for bandwidth estimation */
......@@ -163,6 +160,11 @@ typedef struct _RtcpStream
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 */
uint32_t last_rtcp_report_snt_s; /* the time of the last rtcp report sent, in send timestamp unit */
uint32_t rtcp_report_snt_interval_r; /* the interval in timestamp unit for receive path between rtcp report sent */
uint32_t rtcp_report_snt_interval_s; /* the interval in timestamp unit for send path between rtcp report sent */
bool_t enabled; /*tells whether we can send RTCP packets */
} RtcpStream;
......@@ -309,6 +311,8 @@ void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno);
void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno);
void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms);
void rtp_session_set_ssrc_changed_threshold(RtpSession *session, int numpackets);
/*low level recv and send functions */
......
......@@ -389,11 +389,12 @@ static void notify_sent_rtcp(RtpSession *session, mblk_t *rtcp){
void rtp_session_rtcp_process_send(RtpSession *session){
RtpStream *st=&session->rtp;
RtcpStream *rtcp_st=&session->rtcp;
mblk_t *m;
if (st->rcv_last_app_ts - st->last_rtcp_report_snt_r > st->rtcp_report_snt_interval
|| st->snd_last_ts - st->last_rtcp_report_snt_s > st->rtcp_report_snt_interval){
st->last_rtcp_report_snt_r=st->rcv_last_app_ts;
st->last_rtcp_report_snt_s=st->snd_last_ts;
if (st->rcv_last_app_ts - rtcp_st->last_rtcp_report_snt_r > rtcp_st->rtcp_report_snt_interval_r
|| st->snd_last_ts - rtcp_st->last_rtcp_report_snt_s > rtcp_st->rtcp_report_snt_interval_s){
rtcp_st->last_rtcp_report_snt_r=st->rcv_last_app_ts;
rtcp_st->last_rtcp_report_snt_s=st->snd_last_ts;
m=make_sr(session);
/* send the compound packet */
notify_sent_rtcp(session,m);
......@@ -404,11 +405,12 @@ void rtp_session_rtcp_process_send(RtpSession *session){
void rtp_session_rtcp_process_recv(RtpSession *session){
RtpStream *st=&session->rtp;
RtcpStream *rtcp_st=&session->rtcp;
mblk_t *m=NULL;
if (st->rcv_last_app_ts - st->last_rtcp_report_snt_r > st->rtcp_report_snt_interval
|| st->snd_last_ts - st->last_rtcp_report_snt_s > st->rtcp_report_snt_interval){
st->last_rtcp_report_snt_r=st->rcv_last_app_ts;
st->last_rtcp_report_snt_s=st->snd_last_ts;
if (st->rcv_last_app_ts - rtcp_st->last_rtcp_report_snt_r > rtcp_st->rtcp_report_snt_interval_r
|| st->snd_last_ts - rtcp_st->last_rtcp_report_snt_s > rtcp_st->rtcp_report_snt_interval_s){
rtcp_st->last_rtcp_report_snt_r=st->rcv_last_app_ts;
rtcp_st->last_rtcp_report_snt_s=st->snd_last_ts;
if (session->rtp.last_rtcp_packet_count<session->rtp.stats.packet_sent){
m=make_sr(session);
......
......@@ -47,8 +47,8 @@ extern int rtcp_rr_init(RtpSession *session, char *buf, int size);
/* this function initialize all session parameter's that depend on the payload type */
static void payload_type_changed(RtpSession *session, PayloadType *pt){
jitter_control_set_payload(&session->rtp.jittctl,pt);
session->rtp.rtcp_report_snt_interval=RTCP_DEFAULT_REPORT_INTERVAL*pt->clock_rate;
rtp_session_set_time_jump_limit(session,session->rtp.time_jump);
rtp_session_set_rtcp_report_interval(session,session->rtcp.interval);
if (pt->type==PAYLOAD_VIDEO){
session->permissive=TRUE;
ortp_message("Using permissive algorithm");
......@@ -284,6 +284,7 @@ rtp_session_init (RtpSession * session, int mode)
rtp_session_set_jitter_buffer_params(session,&jbp);
rtp_session_set_time_jump_limit(session,5000);
rtp_session_enable_rtcp(session,TRUE);
rtp_session_set_rtcp_report_interval(session,RTCP_DEFAULT_REPORT_INTERVAL);
session->recv_buf_size = UDP_MAX_SIZE;
session->symmetric_rtp = FALSE;
session->permissive=FALSE;
......@@ -401,6 +402,28 @@ void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno){
session->rtcp.enabled=yesno;
}
/**
* Sets the default interval in milliseconds for RTCP reports emitted by the session
*
**/
void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms){
int recvpt=rtp_session_get_recv_payload_type(session);
int sendpt=rtp_session_get_send_payload_type(session);
if (recvpt!=-1){
PayloadType *pt=rtp_profile_get_payload(session->rcv.profile,recvpt);
if (pt!=NULL){
session->rtcp.rtcp_report_snt_interval_r=(value_ms*pt->clock_rate)/1000;
}
}
if (sendpt!=-1){
PayloadType *pt=rtp_profile_get_payload(session->snd.profile,sendpt);
if (pt!=NULL){
session->rtcp.rtcp_report_snt_interval_s=(value_ms*pt->clock_rate)/1000;
}
}
session->rtcp.interval=value_ms;
}
/**
* Set the RTP profile to be used for the sending by this session. By default, all session are created by
* rtp_session_new() are initialized with the AV profile, as defined in RFC 3551. The application
......
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