[asterisk-commits] oej: branch oej/pinefrog-1.4 r240326 - in /team/oej/pinefrog-1.4: ./ channels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 15 08:04:35 CST 2010


Author: oej
Date: Fri Jan 15 08:04:32 2010
New Revision: 240326

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=240326
Log:
Oh the joy of airport hacking...
- Fix a duration based on RTP instead of CDR, because the CDR will be gone when we need it...
- Minor edits and todos

Modified:
    team/oej/pinefrog-1.4/README.pinefrog-rtcp
    team/oej/pinefrog-1.4/channels/chan_sip.c
    team/oej/pinefrog-1.4/include/asterisk/rtp.h
    team/oej/pinefrog-1.4/main/rtp.c

Modified: team/oej/pinefrog-1.4/README.pinefrog-rtcp
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-1.4/README.pinefrog-rtcp?view=diff&rev=240326&r1=240325&r2=240326
==============================================================================
--- team/oej/pinefrog-1.4/README.pinefrog-rtcp (original)
+++ team/oej/pinefrog-1.4/README.pinefrog-rtcp Fri Jan 15 08:04:32 2010
@@ -64,6 +64,14 @@
 - Added more information to RTCP debug
 - Added more data aggregation to ast_rtcp structure (from svn trunk really)
 
+Open Issues
+-----------
+The final manager report lacks (in the case of the second channel) the bridged channel. We could save that data. 
+
+Do we have a counter of consecutive lost packets? How do we measure lost packets on inbound
+stream? Gaps in seq numbers or just the sender reports from the other end compared with received 
+no of packets?
+
 
 Ideas and thoughts for the future
 ---------------------------------

Modified: team/oej/pinefrog-1.4/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-1.4/channels/chan_sip.c?view=diff&rev=240326&r1=240325&r2=240326
==============================================================================
--- team/oej/pinefrog-1.4/channels/chan_sip.c (original)
+++ team/oej/pinefrog-1.4/channels/chan_sip.c Fri Jan 15 08:04:32 2010
@@ -13442,20 +13442,29 @@
 	char localjitter[10], remotejitter[10];
 	int qosrealtime = ast_check_realtime("rtpqos");
 	long int duration;	/* Duration in secs */
-
-	if (p && p->owner && p->owner->cdr && !ast_tvzero(p->owner->cdr->start)) {
-		duration = (long int)(ast_tvdiff_ms(ast_tvnow(), p->owner->cdr->start) / 1000);
+	struct ast_channel *bridgepeer = NULL;
+
+	if (p && p->owner) {
+		bridgepeer = ast_bridged_channel(p->owner);
+
 	}
 
 	if (global_rtcpevents) {
 		rtpqstring =  ast_rtp_get_quality(rtp, &qual);
+		/* 
+		   If numberofreports == 0 we have no incoming RTCP active, thus we can't
+		   get any reliable data to handle packet loss or any RTT timing.
+		*/
+		duration = (long int)(ast_tvdiff_ms(ast_tvnow(), qual.start) / 1000);
 		manager_event(EVENT_FLAG_CALL, "RTPQuality", 
 			"Channel: %s\r\n"			/* AST_CHANNEL for this call */
+			"BridgedChannel: %s\r\n"
 			"RTPreporttype: %s\r\n"
-			"Duration: %ld\r\n"
-			"PVTcallid: %s\r\n"
+			"RTPrtcpstatus: %s\r\n"
+			"Duration: %ld\r\n"		/* used in cdr_manager */
+			"PvtCallid: %s\r\n"		/* ??? Generic PVT identifier */
 			"RTPipaddress: %s\r\n"
-			"RTPmedia: %s\r\n"
+			"RTPmedia: %s\r\n"		/* Audio, video, text */
 			"RTPsendformat: %s\r\n"
 			"RTPrecvformat: %s\r\n"
 			"RTPlocalssrc: %u\r\n"
@@ -13465,13 +13474,15 @@
 			"RTPrttMin: %f\r\n"
 			"RTPLocalJitter: %f\r\n"
 			"RTPRemoteJitter: %f\r\n" 
-			"RTPLocalPacketLoss: %d\r\n" 
-			"RTPLocalPLPercent: %5.2f\r\n"
-			"RTPRemotePacketLoss: %d\r\n"
-			"RTPRemotePLPercent: %5.2f\r\n"
+			"RTPInPacketLoss: %d\r\n" 
+			"RTPInLocalPlPercent: %5.2f\r\n"
+			"RTPOutPacketLoss: %d\r\n"
+			"RTPOutPlPercent: %5.2f\r\n"
 			"\r\n", 
 			p->owner ? p->owner->name : "",
+			bridgepeer ? bridgepeer->name : "",
 			endreport ? "Final" : "Update",
+			qual.numberofreports == 0 ? "Inactive" : "Active",
 			duration,
 			p->callid, 
 			ast_inet_ntoa(qual.them.sin_addr), 	
@@ -13486,9 +13497,13 @@
 			qual.local_jitter,
 			qual.remote_jitter,
 			qual.local_lostpackets,
-			(qual.remote_count + qual.remote_lostpackets) > 0 ? (double) qual.remote_lostpackets / qual.remote_count  * 100 : 0,
+			/* The local counter of lost packets in inbound stream divided with received packets plus lost packets */
+			(qual.remote_count + qual.local_lostpackets) > 0 ? (double) qual.local_lostpackets / (qual.remote_count + qual.local_lostpackets) * 100 : 0,
 			qual.remote_lostpackets,
-			(qual.local_count + qual.local_lostpackets) > 0 ? (double) qual.local_lostpackets / (qual.local_count + qual.local_lostpackets) * 100 : 0
+			/* The remote counter of lost packets (if we got the reports)
+			   divided with our counter of sent packets
+			 */
+			(qual.local_count + qual.remote_lostpackets) > 0 ? (double) qual.remote_lostpackets / qual.local_count  * 100 : 0
 			);
 	}
 	/* CDR records are not reliable when it comes to near-death-of-channel events, so we need to store the RTCP

Modified: team/oej/pinefrog-1.4/include/asterisk/rtp.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-1.4/include/asterisk/rtp.h?view=diff&rev=240326&r1=240325&r2=240326
==============================================================================
--- team/oej/pinefrog-1.4/include/asterisk/rtp.h (original)
+++ team/oej/pinefrog-1.4/include/asterisk/rtp.h Fri Jan 15 08:04:32 2010
@@ -79,6 +79,7 @@
 
 /*! \brief Data structure only used for RTCP reports */
 struct ast_rtp_quality {
+	unsigned int numberofreports;	  /*!< Number of reports received from remote end */
 	unsigned int local_ssrc;          /*!< Our SSRC */
 	unsigned int local_lostpackets;   /*!< Our lost packets */
 	double       local_jitter;        /*!< Our calculated jitter */
@@ -97,6 +98,7 @@
 	int lasttxformat;		  /*!< Last used codec on transmitted stream */
 	int lastrxformat;		  /*!< Last used codec on received stream */
 	struct sockaddr_in them;	  /*!< The Ip address used for media by remote end */
+	struct timeval start;		  /*!< When the call started */
 };
 
 

Modified: team/oej/pinefrog-1.4/main/rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-1.4/main/rtp.c?view=diff&rev=240326&r1=240325&r2=240326
==============================================================================
--- team/oej/pinefrog-1.4/main/rtp.c (original)
+++ team/oej/pinefrog-1.4/main/rtp.c Fri Jan 15 08:04:32 2010
@@ -174,6 +174,7 @@
 	struct timeval rxcore;
 	struct timeval txcore;
 	double drxcore;                 /*!< The double representation of the first received packet */
+	struct timeval start;		/*!< When the stream started (we can't depend on CDRs) */
 	struct timeval lastrx;          /*!< timeval when we last received a packet */
 	struct timeval dtmfmute;
 	struct ast_smoother *smoother;
@@ -956,6 +957,7 @@
 	unsigned int msw;
 	unsigned int lsw;
 	unsigned int comp;
+	double reported_jitter, reported_lost;
 	struct ast_frame *f = &ast_null_frame;
 	
 	if (!rtp || !rtp->rtcp)
@@ -1084,11 +1086,13 @@
 				if (comp - dlsr >= lsr) {
 					rtp->rtcp->accumulated_transit += rttsec;
 					rtp->rtcp->rtt = rttsec;
-					if (rtp->rtcp->maxrtt < rttsec)
+					if (rtp->rtcp->maxrtt < rttsec) {
 						rtp->rtcp->maxrtt = rttsec;
+					}
 					if (rtp->rtcp->minrtt > rttsec || rtp->rtcp->minrtt == 0) {
 						rtp->rtcp->minrtt = rttsec;
 					}
+					rtp->rtcp->rtt_count++;
 				} else if (rtcp_debug_test_addr(&sin)) {
 					ast_verbose("Internal RTCP NTP clock skew detected: "
 							   "lsr=%u, now=%u, dlsr=%u (%d:%03dms), "
@@ -1100,12 +1104,21 @@
 			}
 
 			rtp->rtcp->reported_jitter = ntohl(rtcpheader[i + 3]);
+			reported_jitter = (double) rtp->rtcp->reported_jitter;
 			if (rtp->rtcp->reported_jitter > rtp->rtcp->reported_maxjitter) {
-				rtp->rtcp->reported_maxjitter = rtp->rtcp->reported_jitter;
+				rtp->rtcp->reported_maxjitter = reported_jitter;
 			} else if (rtp->rtcp->reported_jitter < rtp->rtcp->reported_minjitter || rtp->rtcp->reported_minjitter == 0) {
-				rtp->rtcp->reported_minjitter = rtp->rtcp->reported_jitter;
+				rtp->rtcp->reported_minjitter = reported_jitter;
 			}
+		
 			rtp->rtcp->reported_lost = ntohl(rtcpheader[i + 1]) & 0xffffff;
+			reported_lost = (double) rtp->rtcp->reported_lost;
+			if (rtp->rtcp->reported_lost > rtp->rtcp->reported_maxlost) {
+				rtp->rtcp->reported_maxlost = reported_lost;
+			} else if (rtp->rtcp->reported_lost < rtp->rtcp->reported_minlost || rtp->rtcp->reported_jitter_count == 0) {
+				rtp->rtcp->reported_minlost = reported_lost;
+			}
+			rtp->rtcp->reported_jitter_count++;
 			if (rtcp_debug_test_addr(&sin)) {
 				ast_verbose("  Fraction lost: %ld\n", (((long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24));
 				ast_verbose("  Packets lost so far: %d\n", rtp->rtcp->reported_lost);
@@ -2168,6 +2181,8 @@
 	ast_set_flag(rtp, FLAG_HAS_DTMF);
 	rtp->isactive = 1;
 
+	gettimeofday(&rtp->start, NULL);
+
 	return;
 }
 
@@ -2412,6 +2427,7 @@
 	*/
 
 	if (qual && rtp) {
+		qual->start = rtp->start;
 		qual->lasttxformat = rtp->lasttxformat;
 		qual->lastrxformat = rtp->lastrxformat;
 		qual->local_ssrc = rtp->ssrc;
@@ -2421,6 +2437,7 @@
 		qual->remote_count = rtp->txcount;
 		qual->them = rtp->them;	/* IP address and port */
 		if (rtp->rtcp) {
+			qual->numberofreports = rtp->rtcp->reported_jitter_count;	/* use the jitter counter */
 			qual->local_jitter_max = rtp->rtcp->maxrxjitter;
 			qual->local_jitter_min = rtp->rtcp->minrxjitter;
 			qual->local_lostpackets = rtp->rtcp->expected_prior - rtp->rtcp->received_prior;




More information about the asterisk-commits mailing list