[svn-commits] oej: branch oej/pinefrog-1.4 r294432 - in /team/oej/pinefrog-1.4: channels/ i...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 9 15:10:23 CST 2010


Author: oej
Date: Tue Nov  9 15:10:09 2010
New Revision: 294432

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=294432
Log:
Testing with one-legged calls revealed a lot of issues in the handling of NULL channels and others.
Also added more data to the realtime reports.

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=294432&r1=294431&r2=294432
==============================================================================
--- team/oej/pinefrog-1.4/channels/chan_sip.c (original)
+++ team/oej/pinefrog-1.4/channels/chan_sip.c Tue Nov  9 15:10:09 2010
@@ -478,6 +478,12 @@
 	{ SIP_OPT_RESPRIORITY,	NOT_SUPPORTED,	"resource-priority" },
 };
 
+/*! Media types for declaration of RTP streams */
+enum media_type {
+	SDP_AUDIO,	/* AUDIO class */
+	SDP_VIDEO,
+	SDP_IMAGE,
+};
 
 /*! \brief SIP Methods we support */
 #define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO"
@@ -1417,6 +1423,7 @@
 static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int add_audio, int add_t38);
 static int send_rtcp_events(const void *data);
 static void start_rtcp_events(struct sip_pvt *dialog);
+static void sip_rtcp_report(struct sip_pvt *p, struct ast_rtp *rtp, enum media_type type, int reporttype);
 static void stop_media_flows(struct sip_pvt *p);
 static void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_quality *qual);
 
@@ -5437,11 +5444,6 @@
 	return;
 }
 
-enum media_type {
-	SDP_AUDIO,	/* AUDIO class */
-	SDP_VIDEO,
-	SDP_IMAGE,
-};
 
 static int get_ip_and_port_from_sdp(struct sip_request *req, const enum media_type media, struct sockaddr_in *sin)
 {
@@ -13821,8 +13823,6 @@
 /*! \brief send manager report of RTCP 
 	reporttype = 0  means report during call (if configured)
 	reporttype = 1  means endof-call (hangup) report
-	reporttype = 2  means report at closure of SIP pvt (used only for realtime reports. We might get 
-			an incoming final RTCP after we send BYE 
 	reporttype = 10  means report at end of call leg (like transfer)
 */
 static void sip_rtcp_report(struct sip_pvt *p, struct ast_rtp *rtp, enum media_type type, int reporttype)
@@ -13839,8 +13839,10 @@
 		struct ast_channel *bridgepeer = ast_bridged_channel(p->owner);
 		if (bridgepeer) {
 			/* Store the bridged peer data while we have it */
-			ast_rtcp_set_bridged(rtp, bridgepeer->name, bridgepeer->uniqueid);
+			ast_rtcp_set_bridged(rtp, p->owner->name, p->owner->uniqueid, S_OR(bridgepeer->name,""), S_OR(bridgepeer->uniqueid,""));
 			ast_log(LOG_DEBUG, "---- Setting bridged peer name to %s\n", bridgepeer->name);
+		} else {
+			ast_rtcp_set_bridged(rtp, p->owner->name, p->owner->uniqueid, NULL, NULL);
 		}
 
  		/* Try to find out if there's active transcoding */
@@ -13865,8 +13867,8 @@
 
 	}
 
-	if (global_rtcpevents && reporttype != 2) {
-		rtpqstring =  ast_rtp_get_quality(rtp, &qual);
+	rtpqstring =  ast_rtp_get_quality(rtp, &qual);
+	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.
@@ -13939,7 +13941,7 @@
 	   the quality report structure in the PVT and let the function that kills the pvt store the stuff in the
 	   monitor thread instead.
 	 */
-	if (reporttype == 2 && qosrealtime) {
+	if (reporttype == 1 && qosrealtime) {
 		if (type == SDP_AUDIO) {  /* Audio */
 			p->audioqual = ast_calloc(sizeof(struct ast_rtp_quality), 1);
 			(* p->audioqual) = qual;
@@ -13963,10 +13965,9 @@
 	char localjitter[10], remotejitter[10];
 	char buf_readcost[5], buf_writecost[5];
 	char buf_mediatype[10];
-
-	/* Update the reports before writing */
-	sip_rtcp_report(dialog, dialog->rtp, SDP_AUDIO, 2);
-	sip_rtcp_report(dialog, dialog->vrtp, SDP_VIDEO, 2);
+	char buf_remoteip[25];
+	char buf_inpacketloss[25], buf_outpacketloss[25];
+	char buf_outpackets[25], buf_inpackets[25];
 
 	/* Since the CDR is already gone, we need to calculate our own duration.
 	   The CDR duration is the definitive resource for billing, this is
@@ -13989,16 +13990,22 @@
 	sprintf(buf_readcost, "%d", qual->readcost);
 	sprintf(buf_writecost, "%d", qual->writecost);
 	sprintf(buf_mediatype,"%s", qual->mediatype == SDP_AUDIO ? "audio" : (qual->mediatype == SDP_VIDEO ? "video" : "fax") );
+	sprintf(buf_remoteip,"%s", ast_inet_ntoa(qual->them.sin_addr));
+	sprintf(buf_inpacketloss, "%d", qual->local_lostpackets);
+	sprintf(buf_outpacketloss, "%d", qual->remote_lostpackets);
+	sprintf(buf_inpackets, "%d", qual->remote_count);	/* Do check again */
+	sprintf(buf_outpackets, "%d", qual->local_count);
 
 	ast_store_realtime("rtpqos", 
-		"channel", dialog->owner ? dialog->owner->name : "", 
-		"uniqueid", dialog->owner ? dialog->owner->uniqueid : "", 
+		"channel", qual->channel[0] ? qual->channel : "--no channel--",
+		"uniqueid", qual->uniqueid[0] ? qual->uniqueid : "--no uniqueid --",
 		"bridgedchan", qual->bridgedchan[0] ? qual->bridgedchan : "" ,
 		"bridgeduniqueid", qual->bridgeduniqueid[0] ? qual->bridgeduniqueid : "",
 		"pvtcallid", dialog->callid, 
 		"rtpmedia", buf_mediatype, 
 		"localssrc", buf_lssrc, 
 		"remotessrc", buf_rssrc,
+		"remoteip", buf_remoteip,
 		"rtt", buf_rtt, 
 		"localjitter", localjitter, 
 		"remotejitter", remotejitter, 
@@ -14006,10 +14013,14 @@
 		"receiveformat", ast_getformatname(qual->lastrxformat),
 		"rtcpstatus", qual->numberofreports == 0 ? "Inactive" : "Active",
 		"duration", buf_duration,
-		"writetranslator", qual->writetranslator,
+		"writetranslator", qual->writetranslator[0] ? qual->writetranslator : "",
 		"writecost", buf_writecost,
-		"readtranslator", qual->readtranslator,
+		"readtranslator", qual->readtranslator[0] ? qual->readtranslator : "",
 		"readcost", buf_readcost,
+		"packetlossin", buf_inpacketloss,
+		"packetlossout", buf_outpacketloss,
+		"packetsent", buf_outpackets,
+		"packetreceived", buf_inpackets,
 		NULL);
 #endif
 }

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=294432&r1=294431&r2=294432
==============================================================================
--- team/oej/pinefrog-1.4/include/asterisk/rtp.h (original)
+++ team/oej/pinefrog-1.4/include/asterisk/rtp.h Tue Nov  9 15:10:09 2010
@@ -79,6 +79,8 @@
 
 /*! \brief Data structure only used for RTCP reports */
 struct ast_rtp_quality {
+	char channel[AST_MAX_EXTENSION];	/*!< Name of channel */
+	char uniqueid[AST_MAX_EXTENSION];	/*!< uniqueid of channel */
 	char bridgedchan[AST_MAX_EXTENSION];	/*!< Name of bridged channel */
 	char bridgeduniqueid[AST_MAX_EXTENSION];	/*!< uniqueid of bridged channel */
 	unsigned int numberofreports;	  /*!< Number of reports received from remote end */
@@ -205,14 +207,14 @@
 /*! \brief Set the transcoding variables for the QoS reports */
 void ast_rtcp_settranslator(struct ast_rtp *rtp, const char *readtranslator, const int readcost, const char *writetranslator, const int writecost);
 
-/*! \brief set the name of the bridged channel
+/*! \brief set the name of the channel and the bridged channel (if any)
 
 At the time when we write the report there might not be a bridge, so we need
 to store this so we can correlate the reports. If a channel changes bridge,
 it can be reset by first setting it to an empty string, then setting to 
 a new name 
 */
-void ast_rtcp_set_bridged(struct ast_rtp *rtp, const char *bridged_name, const char *bridged_uniqueid);
+void ast_rtcp_set_bridged(struct ast_rtp *rtp, const char *channel, const char *uniqueid, const char *bridged_name, const char *bridged_uniqueid);
 
 /*! \brief Store translator information
 

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=294432&r1=294431&r2=294432
==============================================================================
--- team/oej/pinefrog-1.4/main/rtp.c (original)
+++ team/oej/pinefrog-1.4/main/rtp.c Tue Nov  9 15:10:09 2010
@@ -281,6 +281,8 @@
 	int sendfur;
 	char bridgedchan[AST_MAX_EXTENSION];		/*!< Bridged channel name */
 	char bridgeduniqueid[AST_MAX_EXTENSION];	/*!< Bridged channel uniqueid */
+	char channel[AST_MAX_EXTENSION];		/*!< Our channel name */
+	char uniqueid[AST_MAX_EXTENSION];	/*!< Our channel uniqueid */
 	char readtranslator[80];	/* Translation done on reading audio from PBX */
 	char writetranslator[80];	/* Translation done on writing audio to PBX - bridged channel */
 	int readcost;			/* Delay in milliseconds for translation of 1 second of audio */
@@ -2426,7 +2428,7 @@
 it can be reset by first setting it to an empty string, then setting to 
 a new name 
 */
-void ast_rtcp_set_bridged(struct ast_rtp *rtp, const char *bridged_name, const char *bridged_uniqueid)
+void ast_rtcp_set_bridged(struct ast_rtp *rtp, const char *channel, const char *uniqueid, const char *bridgedchan, const char *bridgeduniqueid)
 {
 	if (!rtp) {		/* For some reason, there's no RTP */
 		return;
@@ -2434,12 +2436,25 @@
 	if (!rtp->rtcp) {	/* No RTCP? Strange */
 		return;
 	}
-	/* If we already have a bridged name, don't overwrite */
-	if (rtp->rtcp->bridgedchan[0]) {
-		return;
-	}
-	ast_copy_string(rtp->rtcp->bridgedchan, bridged_name, sizeof(rtp->rtcp->bridgedchan));
-	ast_copy_string(rtp->rtcp->bridgeduniqueid, bridged_uniqueid, sizeof(rtp->rtcp->bridgeduniqueid));
+	/* If we already have data, don't replace it. 
+		NOTE: Should we replace it at a masquerade or something? Hmm.
+	*/
+	if (channel && !rtp->rtcp->channel[0]) {
+		ast_copy_string(rtp->rtcp->channel, channel, sizeof(rtp->rtcp->channel));
+	}
+	if (uniqueid && !rtp->rtcp->uniqueid[0]) {
+		ast_copy_string(rtp->rtcp->uniqueid, uniqueid, sizeof(rtp->rtcp->uniqueid));
+	}
+	if (bridgedchan) {
+		ast_copy_string(rtp->rtcp->bridgedchan, bridgedchan, sizeof(rtp->rtcp->bridgedchan));
+	} else {
+		rtp->rtcp->bridgedchan[0] = '\0';
+	}
+	if (bridgeduniqueid) {
+		ast_copy_string(rtp->rtcp->bridgeduniqueid, bridgeduniqueid, sizeof(rtp->rtcp->bridgeduniqueid));
+	} else {
+		rtp->rtcp->bridgeduniqueid[0] = '\0';
+	}
 }
 
 int ast_rtp_settos(struct ast_rtp *rtp, int tos)
@@ -2593,8 +2608,9 @@
 		qual->local_count = rtp->rxcount;
 		qual->remote_ssrc = rtp->themssrc;
 		qual->remote_count = rtp->txcount;
-		qual->them = rtp->them;	/* IP address and port */
+		ast_log(LOG_DEBUG, "OEJ ---Setting remote RTP IP to %s\n", ast_inet_ntoa(rtp->them.sin_addr));
 		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;
@@ -2606,11 +2622,23 @@
 			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 (!ast_strlen_zero(rtp->rtcp->bridgedchan)) {
 				ast_copy_string(qual->bridgedchan, rtp->rtcp->bridgedchan, sizeof(qual->bridgedchan));
 			}
 			if (!ast_strlen_zero(rtp->rtcp->bridgeduniqueid)) {
 				ast_copy_string(qual->bridgeduniqueid, rtp->rtcp->bridgeduniqueid, sizeof(qual->bridgeduniqueid));
+			}
+			if (!ast_strlen_zero(rtp->rtcp->channel)) {
+				ast_copy_string(qual->channel, rtp->rtcp->channel, sizeof(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;




More information about the svn-commits mailing list