uint32_thigh_ext_seq_recv;/* Packet loss calculation, highest extended sequence number received and processed for stats */
uint16_tcycle;/* Packet loss calculation, sequence number cycle of the current RTCP report interval */
uint32_tbad_seq;/* Bad SEQ found, used to detect reset on the other side */
uint16_tbase_seq;/* Packet loss calculation, first sequence number received */
uint32_tcum_lost;/* Packet loss calculation, cumulative number of packet lost */
uint32_tlast_recv_lsr_local;/* RTT calculation, When receiving an SR we save our local timestamp in fraction of 65536 seconds */
uint32_tlast_recv_lsr_peer;/* RTT calculation, When receiving an SR we extract the middle 32bits of the remote NTP timestamp to include it in the next SR LSR */
}switch_rtcp_numbers_t;
typedefstruct{
...
...
@@ -884,7 +900,7 @@ typedef struct {
#endif
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
typedefstruct{
typedefstructswitch_rtcp_hdr_s{
unsignedversion:2;/* protocol version */
unsignedp:1;/* padding flag */
unsignedcount:5;/* number of reception report blocks */
...
...
@@ -894,7 +910,7 @@ typedef struct {
#else /* BIG_ENDIAN */
typedefstruct{
typedefstructswitch_rtcp_hdr_s{
unsignedcount:5;/* number of reception report blocks */
ntp_sec=sec+NTP_TIME_OFFSET;/* convert to NTP seconds */
sr->ntp_msw=htonl(ntp_sec);/* store result in "most significant word" */
ntp_usec=now-(sec*1000000);/* remove seconds to keep only the microseconds */
sr->ntp_lsw=htonl(ntp_usec*(double)(((uint64_t)1)<<32)*1.0e-6);/* convert microseconds to fraction of 32bits and store result in "least significatn word" */
/* Delay since Last Sender Report (DLSR) : 32bits, 1/65536 seconds */
lsr_now=(uint32_t)(ntp_usec*0.065536)|(ntp_sec&0x0000ffff)<<16;/* 0.065536 is used for convertion from useconds to fraction of 65536 (x65536/1000000) */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),SWITCH_LOG_DEBUG,"RTCP send rate is: %d and packet rate is: %d Remote Port: %d\n",send_rate,rtp_session->ms_per_packet,rtp_session->remote_rtcp_port);
/* Extracting LSR from NTP timestamp and save it */
lsr=(ntohl(sr->sender_info.ntp_lsw)&0xffff0000)>>16|(ntohl(sr->sender_info.ntp_msw)&0x0000ffff)<<16;/* The middle 32 bits out of 64 in the NTP timestamp */
rtp_session->stats.rtcp.last_recv_lsr_peer=htonl(lsr);/* Save it include it in the next SR */
rtp_session->stats.rtcp.last_recv_lsr_local=lsr_now;/* Save it to calculate DLSR when generating next SR */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),SWITCH_LOG_DEBUG10,"Received a SR with %d report blocks, " \
/* Currently in passthru mode RTT will not be accurate, some work as to be done (something like mapping the NTP timestamp with a local one) to have RTT from both legs */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),SWITCH_LOG_DEBUG10,"Received an RTCP packet of length %"SWITCH_SIZE_T_FMT" bytes\n",*bytes);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),SWITCH_LOG_DEBUG10,"RTCP packet type is %d\n",rtp_session->rtcp_recv_msg_p->header.type);