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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 8 02:41:45 CDT 2011


Author: oej
Date: Thu Sep  8 02:41:40 2011
New Revision: 334905

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334905
Log:
Adding some new code that I totally forgot to check in

Modified:
    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/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-1.4/channels/chan_sip.c?view=diff&rev=334905&r1=334904&r2=334905
==============================================================================
--- team/oej/pinefrog-1.4/channels/chan_sip.c (original)
+++ team/oej/pinefrog-1.4/channels/chan_sip.c Thu Sep  8 02:41:40 2011
@@ -3990,9 +3990,9 @@
 				char *audioqos = "";
 				char *videoqos = "";
 				if (p->rtp)
-					audioqos = ast_rtp_get_quality(p->rtp, NULL);
+					audioqos = ast_rtp_get_quality(p->rtp);
 				if (p->vrtp)
-					videoqos = ast_rtp_get_quality(p->vrtp, NULL);
+					videoqos = ast_rtp_get_quality(p->vrtp);
 				/* Send a hangup */
 				if (oldowner->_state == AST_STATE_UP) {
 					transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
@@ -14097,7 +14097,7 @@
 */
 static void sip_rtcp_report(struct sip_pvt *p, struct ast_rtp *rtp, enum media_type type, int reporttype)
 {
-	struct ast_rtp_quality qual;
+	struct ast_rtp_quality *qual;
 	char *rtpqstring = NULL;
 	int qosrealtime = ast_check_realtime("rtpqos");
 	unsigned int duration;	/* Duration in secs */
@@ -14137,13 +14137,20 @@
 
 	}
 
-	rtpqstring =  ast_rtp_get_quality(rtp, &qual);
+	rtpqstring =  ast_rtp_get_quality(rtp);
+	qual = ast_rtp_get_qualdata(rtp);
+	if (!qual) {
+		/* Houston, we got a problem */
+		return;
+	}
+	
 	if (global_rtcpevents) {
 		/* 
 		   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 = (unsigned int)(ast_tvdiff_ms(ast_tvnow(), qual.start) / 1000);
+
+		duration = (unsigned int)(ast_tvdiff_ms(ast_tvnow(), qual->start) / 1000);
 		manager_event(EVENT_FLAG_CALL, "RTPQuality", 
 			"Channel: %s\r\n"			/* AST_CHANNEL for this call */
 			"Uniqueid: %s\r\n"			/* AST_CHANNEL for this call */
@@ -14175,33 +14182,33 @@
 			"\r\n", 
 			p->owner ? p->owner->name : "",
 			p->owner ? p->owner->uniqueid : "",
-			qual.bridgedchan[0] ? qual.bridgedchan : "" ,
-			qual.bridgeduniqueid[0] ? qual.bridgeduniqueid : "",
+			qual->bridgedchan[0] ? qual->bridgedchan : "" ,
+			qual->bridgeduniqueid[0] ? qual->bridgeduniqueid : "",
 			reporttype == 1 ? "Final" : "Update",
-			qual.numberofreports == 0 ? "Inactive" : "Active",
+			qual->numberofreports == 0 ? "Inactive" : "Active",
 			duration,
 			p->callid, 
-			ast_inet_ntoa(qual.them.sin_addr), 	
+			ast_inet_ntoa(qual->them.sin_addr), 	
 			type == SDP_AUDIO ? "audio" : (type == SDP_VIDEO ? "video" : "fax") ,
-			ast_getformatname(qual.lasttxformat),
-			ast_getformatname(qual.lastrxformat),
-			qual.local_ssrc, 
-			qual.remote_ssrc,
-			qual.rtt,
-			qual.rttmax,
-			qual.rttmin,
-			qual.local_jitter,
-			qual.remote_jitter,
-			qual.local_lostpackets,
+			ast_getformatname(qual->lasttxformat),
+			ast_getformatname(qual->lastrxformat),
+			qual->local_ssrc, 
+			qual->remote_ssrc,
+			qual->rtt,
+			qual->rttmax,
+			qual->rttmin,
+			qual->local_jitter,
+			qual->remote_jitter,
+			qual->local_lostpackets,
 			/* 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->remote_count + qual->local_lostpackets) > 0 ? (double) qual->local_lostpackets / (qual->remote_count + qual->local_lostpackets) * 100 : 0,
+			qual->remote_lostpackets,
 			/* 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,
-			qual.readtranslator, qual.readcost,
-			qual.writetranslator, qual.writecost
+			(qual->local_count + qual->remote_lostpackets) > 0 ? (double) qual->remote_lostpackets / qual->local_count  * 100 : 0,
+			qual->readtranslator, qual->readcost,
+			qual->writetranslator, qual->writecost
 		);
 	}
 
@@ -14229,9 +14236,9 @@
 /*! \brief Write quality report to realtime storage */
 void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_quality *qual)
 {
-#ifdef REALTIME2
 	unsigned int duration;	/* Duration in secs */
-	char buf_duration[10], buf_lssrc[30], buf_rssrc[30], buf_rtt[30];
+	char buf_duration[10], buf_lssrc[30], buf_rssrc[30];
+	char buf_rtt[10], buf_rttmin[10], buf_rttmax[10];
 	char localjitter[10], remotejitter[10];
 	char buf_readcost[5], buf_writecost[5];
 	char buf_mediatype[10];
@@ -14255,7 +14262,9 @@
 	sprintf(remotejitter, "%f", qual->remote_jitter);
 	sprintf(buf_lssrc, "%u", qual->local_ssrc);
 	sprintf(buf_rssrc, "%u", qual->remote_ssrc);
-	sprintf(buf_rtt, "%f", qual->rtt);
+	sprintf(buf_rtt, "%.0f", qual->rtt);
+	sprintf(buf_rttmax, "%.0f", qual->rttmax);
+	sprintf(buf_rttmin, "%.0f", qual->rttmin);
 	sprintf(buf_duration, "%u", duration);
 	sprintf(buf_readcost, "%d", qual->readcost);
 	sprintf(buf_writecost, "%d", qual->writecost);
@@ -14266,6 +14275,27 @@
 	sprintf(buf_inpackets, "%d", qual->remote_count);	/* Do check again */
 	sprintf(buf_outpackets, "%d", qual->local_count);
 
+	ast_log(LOG_NOTICE,"RTPQOS Channel: %s Uid %s Bch %s Buid %s Pvt %s Media %s Lssrc %s Rssrc %s Rip %s Rtt %s:%s:%s Ljitter %s Rjitter %s Rtcpstatus %s Dur %s Pout %s Plossout %s Pin %s Plossin %s\n",
+		qual->channel[0] ? qual->channel : "",
+		qual->uniqueid[0] ? qual->uniqueid : "",
+		qual->bridgedchan[0] ? qual->bridgedchan : "" ,
+		qual->bridgeduniqueid[0] ? qual->bridgeduniqueid : "",
+		dialog->callid,
+		buf_mediatype,
+		buf_lssrc,
+		buf_rssrc,
+		buf_remoteip,
+		buf_rtt, buf_rttmax, buf_rttmin,
+		localjitter,
+		remotejitter,
+		qual->numberofreports == 0 ? "Inactive" : "Active",
+		buf_duration,
+		buf_outpackets,
+		buf_outpacketloss,
+		buf_inpackets,
+		buf_inpacketloss);
+
+#ifdef REALTIME2
 	ast_store_realtime("rtpqos", 
 		"channel", qual->channel[0] ? qual->channel : "--no channel--",
 		"uniqueid", qual->uniqueid[0] ? qual->uniqueid : "--no uniqueid --",
@@ -14277,6 +14307,8 @@
 		"remotessrc", buf_rssrc,
 		"remoteip", buf_remoteip,
 		"rtt", buf_rtt, 
+		"rttmax", buf_rttmax, 
+		"rttmin", buf_rttmin, 
 		"localjitter", localjitter, 
 		"remotejitter", remotejitter, 
 		"sendformat", ast_getformatname(qual->lasttxformat),
@@ -16895,14 +16927,14 @@
 	if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY) || p->owner) {
 		char *audioqos, *videoqos;
 		if (p->rtp) {
-			audioqos = ast_rtp_get_quality(p->rtp, NULL);
+			audioqos = ast_rtp_get_quality(p->rtp);
 			if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY))
 				append_history(p, "RTCPaudio", "Quality:%s", audioqos);
 			if (p->owner)
 				pbx_builtin_setvar_helper(p->owner, "RTPAUDIOQOS", audioqos);
 		}
 		if (p->vrtp) {
-			videoqos = ast_rtp_get_quality(p->vrtp, NULL);
+			videoqos = ast_rtp_get_quality(p->vrtp);
 			if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY))
 				append_history(p, "RTCPvideo", "Quality:%s", videoqos);
 			if (p->owner)

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=334905&r1=334904&r2=334905
==============================================================================
--- team/oej/pinefrog-1.4/include/asterisk/rtp.h (original)
+++ team/oej/pinefrog-1.4/include/asterisk/rtp.h Thu Sep  8 02:41:40 2011
@@ -101,7 +101,7 @@
 	double       rttmin;              /*!< Max observed round trip time */
 	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 sockaddr_in them;	  /*!< The IP address used for media by remote end */
 	struct timeval start;		  /*!< When the call started */
 	struct timeval end;		  /*!< When the call ended */
 	char writetranslator[80];	  /*!< Translator used when writing */
@@ -297,7 +297,10 @@
 int ast_rtp_isactive(struct ast_rtp *rtp);
 
 /*! \brief Return RTCP quality string */
-char *ast_rtp_get_quality(struct ast_rtp *rtp, struct ast_rtp_quality *qual);
+char *ast_rtp_get_quality(struct ast_rtp *rtp);
+  
+/*! \brief Return RTCP quality data structure */
+struct ast_rtp_quality *ast_rtp_get_qualdata(struct ast_rtp *rtp);
 
 /*! \brief Send an H.261 fast update request. Some devices need this rather than the XML message  in SIP */
 int ast_rtcp_send_h261fur(void *data);

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=334905&r1=334904&r2=334905
==============================================================================
--- team/oej/pinefrog-1.4/main/rtp.c (original)
+++ team/oej/pinefrog-1.4/main/rtp.c Thu Sep  8 02:41:40 2011
@@ -195,6 +195,7 @@
 	struct ast_rtcp *rtcp;
 	struct ast_codec_pref pref;
 	struct ast_rtp *bridged;        /*!< Who we are Packet bridged to */
+	struct ast_rtp_quality *qual;	/*!< Optional QoS data storage for this stream */
 	int set_marker_bit:1;           /*!< Whether to set the marker bit or not */
 	int isactive:2;                 /*!< Whether the RTP stream is active or not */
 };
@@ -2585,7 +2586,12 @@
 	rtp->rxseqno = 0;
 }
 
-char *ast_rtp_get_quality(struct ast_rtp *rtp, struct ast_rtp_quality *qual)
+struct ast_rtp_quality *ast_rtp_get_qualdata(struct ast_rtp *rtp)
+{
+	return(rtp->qual);
+}
+
+char *ast_rtp_get_quality(struct ast_rtp *rtp)
 {
 	/*
 	*ssrc          our ssrc
@@ -2599,57 +2605,65 @@
 	*rtt           round trip time
 	*/
 
-	if (qual && rtp) {
-		qual->start = rtp->start;
-		qual->lasttxformat = rtp->lasttxformat;
-		qual->lastrxformat = rtp->lastrxformat;
-		qual->local_ssrc = rtp->ssrc;
-		qual->local_jitter = rtp->rxjitter;
-		qual->local_count = rtp->rxcount;
-		qual->remote_ssrc = rtp->themssrc;
-		qual->remote_count = rtp->txcount;
-		ast_log(LOG_DEBUG, "OEJ ---Setting remote RTP IP to %s\n", ast_inet_ntoa(rtp->them.sin_addr));
+	if (!rtp->qual) {
+		if (!(rtp->qual = ast_calloc(1, sizeof(*rtp->qual)))) {
+			ast_log(LOG_ERROR, "Memory allocation error.\n");
+		}
+	}
+	if (rtp->qual && rtp) {
+		rtp->qual->start = rtp->start;
+		rtp->qual->lasttxformat = rtp->lasttxformat;
+		rtp->qual->lastrxformat = rtp->lastrxformat;
+		rtp->qual->local_ssrc = rtp->ssrc;
+		rtp->qual->local_jitter = rtp->rxjitter;
+		rtp->qual->local_count = rtp->rxcount;
+		rtp->qual->remote_ssrc = rtp->themssrc;
+		rtp->qual->remote_count = rtp->txcount;
 		if (rtp->rtcp) {
-			qual->them = rtp->rtcp->them;	/* IP address and port */
-			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;
-			qual->remote_lostpackets = rtp->rtcp->reported_lost;
-			qual->remote_jitter = rtp->rtcp->reported_jitter / 65536.0;
-			qual->remote_jitter_max = rtp->rtcp->reported_maxjitter;
-			qual->remote_jitter_min = rtp->rtcp->reported_minjitter;
-			qual->rtt = rtp->rtcp->rtt;
-			qual->rttmax = rtp->rtcp->maxrtt;
-			qual->rttmin = rtp->rtcp->minrtt;
-			qual->channel[0] = '\0';
-			qual->uniqueid[0] = '\0';
-			qual->bridgedchan[0] = '\0';
-			qual->bridgeduniqueid[0] = '\0';
-			qual->readtranslator[0] = '\0';
-			qual->writetranslator[0] = '\0';
+			if (rtp->rtcp->them.sin_addr.s_addr) {
+				/* Do not change to empty address */
+				memcpy(&rtp->qual->them, &rtp->rtcp->them, sizeof(rtp->qual->them));
+			}
+			rtp->qual->numberofreports = rtp->rtcp->reported_jitter_count;	/* use the jitter counter */
+			rtp->qual->local_jitter_max = rtp->rtcp->maxrxjitter;
+			rtp->qual->local_jitter_min = rtp->rtcp->minrxjitter;
+			rtp->qual->local_lostpackets = rtp->rtcp->expected_prior - rtp->rtcp->received_prior;
+			rtp->qual->remote_lostpackets = rtp->rtcp->reported_lost;
+			rtp->qual->remote_jitter = rtp->rtcp->reported_jitter / 65536.0;
+			rtp->qual->remote_jitter_max = rtp->rtcp->reported_maxjitter;
+			rtp->qual->remote_jitter_min = rtp->rtcp->reported_minjitter;
+			rtp->qual->rtt = rtp->rtcp->rtt;
+			rtp->qual->rttmax = rtp->rtcp->maxrtt;
+			rtp->qual->rttmin = rtp->rtcp->minrtt;
+			rtp->qual->channel[0] = '\0';
+			rtp->qual->uniqueid[0] = '\0';
+			rtp->qual->bridgedchan[0] = '\0';
+			rtp->qual->bridgeduniqueid[0] = '\0';
+			rtp->qual->readtranslator[0] = '\0';
+			rtp->qual->writetranslator[0] = '\0';
 			if (!ast_strlen_zero(rtp->rtcp->bridgedchan)) {
-				ast_copy_string(qual->bridgedchan, rtp->rtcp->bridgedchan, sizeof(qual->bridgedchan));
+				ast_copy_string(rtp->qual->bridgedchan, rtp->rtcp->bridgedchan, sizeof(rtp->qual->bridgedchan));
 			}
 			if (!ast_strlen_zero(rtp->rtcp->bridgeduniqueid)) {
-				ast_copy_string(qual->bridgeduniqueid, rtp->rtcp->bridgeduniqueid, sizeof(qual->bridgeduniqueid));
+				ast_copy_string(rtp->qual->bridgeduniqueid, rtp->rtcp->bridgeduniqueid, sizeof(rtp->qual->bridgeduniqueid));
 			}
 			if (!ast_strlen_zero(rtp->rtcp->channel)) {
-				ast_copy_string(qual->channel, rtp->rtcp->channel, sizeof(qual->channel));
+				ast_copy_string(rtp->qual->channel, rtp->rtcp->channel, sizeof(rtp->qual->channel));
 			}
 			if (!ast_strlen_zero(rtp->rtcp->uniqueid)) {
-				ast_copy_string(qual->uniqueid, rtp->rtcp->uniqueid, sizeof(qual->uniqueid));
-			}
-			qual->readcost = rtp->rtcp->readcost;
-			qual->writecost = rtp->rtcp->writecost;
+				ast_copy_string(rtp->qual->uniqueid, rtp->rtcp->uniqueid, sizeof(rtp->qual->uniqueid));
+			}
+			rtp->qual->readcost = rtp->rtcp->readcost;
+			rtp->qual->writecost = rtp->rtcp->writecost;
 			if (!ast_strlen_zero(rtp->rtcp->readtranslator)) {
-				ast_copy_string(qual->readtranslator, rtp->rtcp->readtranslator, sizeof(qual->readtranslator));
+				ast_copy_string(rtp->qual->readtranslator, rtp->rtcp->readtranslator, sizeof(rtp->qual->readtranslator));
 			}
 			if (!ast_strlen_zero(rtp->rtcp->writetranslator)) {
-				ast_copy_string(qual->writetranslator, rtp->rtcp->writetranslator, sizeof(qual->writetranslator));
-			}
-		}
-	}
+				ast_copy_string(rtp->qual->writetranslator, rtp->rtcp->writetranslator, sizeof(rtp->qual->writetranslator));
+			}
+		}
+	}
+	/* The old way */
 	if (rtp->rtcp) {
 		snprintf(rtp->rtcp->quality, sizeof(rtp->rtcp->quality),
 			"ssrc=%u;themssrc=%u;lp=%u;rxjitter=%f;rxcount=%u;txjitter=%f;txcount=%u;rlp=%u;rtt=%f",
@@ -2663,8 +2677,9 @@
 			rtp->rtcp->reported_lost,
 			rtp->rtcp->rtt);
 		return rtp->rtcp->quality;
-	} else
+	} else {
 		return "<Unknown> - RTP/RTCP has already been destroyed";
+	}
 }
 
 void ast_rtp_destroy(struct ast_rtp *rtp)
@@ -2722,6 +2737,10 @@
 		close(rtp->rtcp->s);
 		free(rtp->rtcp);
 		rtp->rtcp=NULL;
+	}
+	if (rtp->qual) {
+		free(rtp->qual);
+		rtp->qual=NULL;
 	}
 
 	ast_mutex_destroy(&rtp->bridge_lock);




More information about the asterisk-commits mailing list