Index: main/rtp.c =================================================================== --- main/rtp.c (revision 47928) +++ main/rtp.c (working copy) @@ -54,6 +54,7 @@ #include "asterisk/lock.h" #include "asterisk/utils.h" #include "asterisk/cli.h" +#include "asterisk/manager.h" #include "asterisk/unaligned.h" #include "asterisk/utils.h" @@ -893,8 +894,10 @@ ast_verbose("SPC: %lu\tSOC: %lu\n", (unsigned long) ntohl(rtcpheader[i + 3]), (unsigned long) ntohl(rtcpheader[i + 4])); } i += 5; - if (rc < 1) + if (rc < 1) { + manager_event(EVENT_FLAG_CALL, "RTCPReceived", "Got RTCP from %s:%d\r\nPT: %d(%s)\r\nReception reports: %d\r\nSSRC of sender: %u\r\nNTP timestamp: %lu.%010lu\r\nRTP timestamp: %lu\r\nSPC: %lu\tSOC: %lu\r\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", rc, rtcpheader[i + 1], (unsigned long) ntohl(rtcpheader[i]), (unsigned long) ntohl(rtcpheader[i + 1]) * 4096, (unsigned long) ntohl(rtcpheader[i + 2]), (unsigned long) ntohl(rtcpheader[i + 3]), (unsigned long) ntohl(rtcpheader[i + 4])); break; + } /* Intentional fall through */ case RTCP_PT_RR: /* This is the place to calculate RTT */ @@ -928,6 +931,10 @@ if (rtt) ast_verbose("RTT: %f(sec)\n", rtt); } + if(rtt) + manager_event(EVENT_FLAG_CALL, "RTCPReceived", "Got RTCP from %s:%d\r\nPT: %d(%s)\r\nReception reports: %d\r\nSSRC of sender: %u\r\nFraction lost: %ld\r\nPackets lost so far: %d\r\nHighest sequence number: %ld\r\nSequence number cycles: %ld\r\nInterarrival jitter: %u\r\nLast SR(our NTP): %lu.%010lu\r\nDLSR: %4.4f (sec)\r\nRTT: %f(sec)\r\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", rc, rtcpheader[i + 1], (((long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24), rtp->rtcp->reported_lost, (long) (ntohl(rtcpheader[i + 2]) & 0xffff), (long) (ntohl(rtcpheader[i + 2]) & 0xffff) >> 16, rtp->rtcp->reported_jitter,(unsigned long) ntohl(rtcpheader[i + 4]) >> 16,((unsigned long) ntohl(rtcpheader[i + 4]) << 16) * 4096,ntohl(rtcpheader[i + 5])/65536.0, rtt); + else + manager_event(EVENT_FLAG_CALL, "RTCPReceived", "Got RTCP from %s:%d\r\nPT: %d(%s)\r\nReception reports: %d\r\nSSRC of sender: %u\r\nFraction lost: %ld\r\nPackets lost so far: %d\r\nHighest sequence number: %ld\r\nSequence number cycles: %ld\r\nInterarrival jitter: %u\r\nLast SR(our NTP): %lu.%010lu\r\nDLSR: %4.4f (sec)\r\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", rc, rtcpheader[i + 1], (((long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24), rtp->rtcp->reported_lost, (long) (ntohl(rtcpheader[i + 2]) & 0xffff), (long) (ntohl(rtcpheader[i + 2]) & 0xffff) >> 16, rtp->rtcp->reported_jitter,(unsigned long) ntohl(rtcpheader[i + 4]) >> 16,((unsigned long) ntohl(rtcpheader[i + 4]) << 16) * 4096,ntohl(rtcpheader[i + 5])/65536.0); break; case RTCP_PT_FUR: if (rtcp_debug_test_addr(&sin)) @@ -2009,6 +2016,9 @@ ast_verbose(" RTT: %f\n", rtp->rtcp->rtt); } + manager_event(EVENT_FLAG_CALL, "RTPRecvStat", "SSRC: %u\r\nReceived packets: %u\r\nLost packets: %u\r\nJitter: %.4f\r\nTransit: %.4f\r\nRR-count: %u\r\n",rtp->themssrc,rtp->rxcount,rtp->rtcp->expected_prior - rtp->rtcp->received_prior,rtp->rxjitter,rtp->rxtransit,rtp->rtcp->rr_count); + manager_event(EVENT_FLAG_CALL, "RTPSndrStat", "SSRC: %u\r\nSent packets: %u\r\nLost packets: %u\r\nJitter: %u\r\nSR-count: %u\r\nRTT: %f\r\n", rtp->ssrc,rtp->txcount,rtp->rtcp->reported_lost,rtp->rtcp->reported_jitter,rtp->rtcp->sr_count,rtp->rtcp->rtt); + if (rtp->smoother) ast_smoother_free(rtp->smoother); if (rtp->ioid) @@ -2323,6 +2333,7 @@ ast_verbose(" Their last SR: %u\n", rtp->rtcp->themrxlsr); ast_verbose(" DLSR: %4.4f (sec)\n\n", (double)(ntohl(rtcpheader[12])/65536.0)); } + manager_event(EVENT_FLAG_CALL, "RTCPSent", "Sent RTCP SR to %s:%d\r\nOur SSRC: %u\r\nSent(NTP): %u.%010u\r\nSent(RTP): %u\r\nSent packets: %u\r\nSent octets: %u\r\nReport block:\r\nFraction lost: %u\r\nCumulative loss: %u\r\nIA jitter: %.4f\r\nTheir last SR: %u\r\nDLSR: %4.4f (sec)\r\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port), rtp->ssrc, (unsigned int)now.tv_sec, (unsigned int)now.tv_usec*4096, rtp->lastts, rtp->txcount, rtp->txoctetcount, fraction, lost, rtp->rxjitter, rtp->rtcp->themrxlsr, (double)(ntohl(rtcpheader[12])/65536.0)); return res; }