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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Sep 11 09:45:56 CDT 2010


Author: oej
Date: Sat Sep 11 09:45:48 2010
New Revision: 286265

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=286265
Log:
Development should move forward. Adding some support for translation time in the reports

Modified:
    team/oej/pinefrog-1.4/   (props changed)
    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

Propchange: team/oej/pinefrog-1.4/
------------------------------------------------------------------------------
    automerge = http://www.codename-pineapple.org/

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=286265&r1=286264&r2=286265
==============================================================================
--- team/oej/pinefrog-1.4/channels/chan_sip.c (original)
+++ team/oej/pinefrog-1.4/channels/chan_sip.c Sat Sep 11 09:45:48 2010
@@ -13570,11 +13570,13 @@
 }
 
 /*! \brief send manager report of RTCP 
-	reporttype = 1  means endof-call report
 	reporttype = 0  means report during call (if configured)
-	reporttype = 2  means report at end of call leg (like transfer)
+	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, const char *mediatype, int reporttype)
+static void sip_rtcp_report(struct sip_pvt *p, struct ast_rtp *rtp, enum media_type type, int reporttype)
 {
 	struct ast_rtp_quality qual;
 	char *rtpqstring = NULL;
@@ -13591,28 +13593,30 @@
 			ast_rtcp_set_bridged(rtp, bridgepeer->name, bridgepeer->uniqueid);
 			ast_log(LOG_DEBUG, "---- Setting bridged peer name to %s\n", bridgepeer->name);
 		}
- 		/* Try to find out if there's transcoding */
- 		readtrans = p->owner->readtrans != NULL;
- 		writetrans = p->owner->writetrans != NULL;
-		if (option_debug > 1) {
-			/* This is just exploring the way into translator system.
-			   if we have a translator, the bridge delay is increased, which affects the QoS 
-			   of the call. If I can get info from the translation matrix too, that would
-			   be great!
-			*/
-			if (option_debug) {
+
+ 		/* Try to find out if there's active transcoding */
+		/* Currently, the only media stream that has translation is the audio stream. At some point
+		   we might have transcoding for other types of media. */
+		if (type == SDP_AUDIO) {
+			/* if we have a translator, the bridge delay is increased, which affects the QoS of the call.  */
+ 			readtrans = p->owner->readtrans != NULL;
+ 			writetrans = p->owner->writetrans != NULL;
+			ast_rtcp_settranslator(rtp, readtrans ? p->owner->readtrans->t->name : NULL, readtrans ? p->owner->readtrans->t->cost : 0,
+					writetrans ? p->owner->writetrans->t->name : NULL, writetrans ? p->owner->writetrans->t->cost : 0);
+		
+			if (option_debug > 1) {
  				if (readtrans && p->owner->readtrans->t) {
- 					ast_log(LOG_DEBUG, "--- Read translator: %s Cost %d\n", p->owner->readtrans->t->name, p->owner->readtrans->t->cost);
+ 					ast_log(LOG_DEBUG, "--- Audio Read translator: %s Cost %d\n", p->owner->readtrans->t->name, p->owner->readtrans->t->cost);
  				}
  				if (writetrans && p->owner->writetrans->t) {
- 					ast_log(LOG_DEBUG, "--- Write translator: %s Cost %d\n", p->owner->writetrans->t->name, p->owner->writetrans->t->cost);
+ 					ast_log(LOG_DEBUG, "--- Audio Write translator: %s Cost %d\n", p->owner->writetrans->t->name, p->owner->writetrans->t->cost);
  				}
 			}
 		}
 
 	}
 
-	if (global_rtcpevents) {
+	if (global_rtcpevents && reporttype != 2) {
 		rtpqstring =  ast_rtp_get_quality(rtp, &qual);
 		/* 
 		   If numberofreports == 0 we have no incoming RTCP active, thus we can't
@@ -13643,8 +13647,10 @@
 			"RTPInLocalPlPercent: %5.2f\r\n"
 			"RTPOutPacketLoss: %d\r\n"
 			"RTPOutPlPercent: %5.2f\r\n"
-			"ChanTranslatRead: %s\r\n"
-			"ChanTranslatWrite: %s\r\n"
+			"TranslateRead: %s\r\n"
+			"TranslateReadCost: %d\r\n"
+			"TranslateWrite: %s\r\n"
+			"TranslateWriteCost: %d\r\n"
 			"\r\n", 
 			p->owner ? p->owner->name : "",
 			p->owner ? p->owner->uniqueid : "",
@@ -13655,7 +13661,7 @@
 			duration,
 			p->callid, 
 			ast_inet_ntoa(qual.them.sin_addr), 	
-			mediatype,
+			type == SDP_AUDIO ? "audio" : (type == SDP_VIDEO ? "video" : "fax") ,
 			ast_getformatname(qual.lasttxformat),
 			ast_getformatname(qual.lastrxformat),
 			qual.local_ssrc, 
@@ -13673,9 +13679,9 @@
 			   divided with our counter of sent packets
 			 */
 			(qual.local_count + qual.remote_lostpackets) > 0 ? (double) qual.remote_lostpackets / qual.local_count  * 100 : 0,
-			readtrans ? "yes" : "no",
-			writetrans ? "yes" : "no"
-			);
+			qual.readtranslator, qual.readcost,
+			qual.writetranslator, qual.writecost
+		);
 	}
 
 	/* CDR records are not reliable when it comes to near-death-of-channel events, so we need to store the RTCP
@@ -13684,12 +13690,12 @@
 	   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 == 1 && qosrealtime) {
-		if (mediatype[0] == 'a') {  /* Audio */
+	if (reporttype == 2 && qosrealtime) {
+		if (type == SDP_AUDIO) {  /* Audio */
 			p->audioqual = ast_calloc(sizeof(struct ast_rtp_quality), 1);
 			(* p->audioqual) = qual;
 			p->audioqual->end = ast_tvnow();
-		} else if (mediatype[0] == 'v') {  /* Video */
+		} else if (type == SDP_VIDEO) {  /* Video */
 			p->videoqual = ast_calloc(sizeof(struct ast_rtp_quality), 1);
 			(* p->videoqual) = qual;
 			p->videoqual->end = ast_tvnow();
@@ -13704,6 +13710,11 @@
 	unsigned int duration;	/* Duration in secs */
 	char buf_duration[10], buf_lssrc[30], buf_rssrc[30], buf_rtt[30];
 	char localjitter[10], remotejitter[10];
+	char buf_readcost[5], buf_writecost[5];
+
+	/* Update the reports before writing */
+	sip_rtcp_report(p, p->rtp, SDP_AUDIO, 2);
+	sip_rtcp_report(p, p->vrtp, SDP_VIDEO, 2);
 
 	/* Since the CDR is already gone, we need to calculate our own duration.
 	   The CDR duration is the definitive resource for billing, this is
@@ -13719,6 +13730,8 @@
 	sprintf(buf_rssrc, "%u", qual->remote_ssrc);
 	sprintf(buf_rtt, "%f", qual->rtt);
 	sprintf(buf_duration, "%u", duration);
+	sprintf(buf_readcost, "%d", qual->readcost);
+	sprintf(buf_writecost, "%d", qual->writecost);
 	ast_store_realtime("rtpqos", 
 		"channel", dialog->owner ? dialog->owner->name : "", 
 		"uniqueid", dialog->owner ? dialog->owner->uniqueid : "", 
@@ -13733,6 +13746,10 @@
 		"receiveformat", ast_getformatname(qual->lastrxformat),
 		"rtcpstatus", qual->numberofreports == 0 ? "Inactive" : "Active",
 		"duration", buf_duration,
+		"writetranslator", qual->writetranslator,
+		"writecost", buf_writecost,
+		"readtranslator", qual->readtranslator,
+		"readcost", buf_readcost,
 		NULL);
 	}
 #endif
@@ -13744,10 +13761,10 @@
 	struct sip_pvt *dialog = (struct sip_pvt *) data;
 
 	if (dialog->rtp && ast_rtp_isactive(dialog->rtp)) {
-		sip_rtcp_report(dialog, dialog->rtp, "audio", FALSE);
+		sip_rtcp_report(dialog, dialog->rtp, SDP_AUDIO, FALSE);
 	}
 	if (dialog->vrtp && ast_rtp_isactive(dialog->vrtp)) {
-		sip_rtcp_report(dialog, dialog->vrtp, "video", FALSE);
+		sip_rtcp_report(dialog, dialog->vrtp, SDP_VIDEO, FALSE);
 	}
 	return global_rtcptimer;
 }
@@ -13775,11 +13792,11 @@
 	/* Immediately stop RTP, VRTP and UDPTL as applicable */
 	if (p->rtp && ast_rtp_isactive(p->rtp)) {
 		ast_rtp_stop(p->rtp);
-		sip_rtcp_report(p, p->rtp, "audio", TRUE);
+		sip_rtcp_report(p, p->rtp, SDP_AUDIO, TRUE);
 	}
 	if (p->vrtp && ast_rtp_isactive(p->vrtp)) {
 		ast_rtp_stop(p->vrtp);
-		sip_rtcp_report(p, p->vrtp, "video", TRUE);
+		sip_rtcp_report(p, p->vrtp, SDP_VIDEO, TRUE);
 	}
 	if (p->udptl)
 		ast_udptl_stop(p->udptl);

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=286265&r1=286264&r2=286265
==============================================================================
--- team/oej/pinefrog-1.4/include/asterisk/rtp.h (original)
+++ team/oej/pinefrog-1.4/include/asterisk/rtp.h Sat Sep 11 09:45:48 2010
@@ -102,8 +102,10 @@
 	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 writetranslate[80];	
-	char readtranslate[80];	
+	char writetranslator[80];	  /*!< Translator used when writing */
+	char readtranslator[80];		  /*!< Translator providing frames when reading */
+	int writecost;		  /*!< Cost in milliseconds for encoding/decoding 1 second of outbound media */
+	int readcost;		  /*!< Cost in milliseconds for encoding/decoding 1 second of inbound media */
 };
 
 
@@ -197,6 +199,9 @@
 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
 
 void ast_rtcp_setcname(struct ast_rtp *rtp, const char *cname, size_t length);
+
+/*! \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
 

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=286265&r1=286264&r2=286265
==============================================================================
--- team/oej/pinefrog-1.4/main/rtp.c (original)
+++ team/oej/pinefrog-1.4/main/rtp.c Sat Sep 11 09:45:48 2010
@@ -281,8 +281,8 @@
 	char bridgedchan[AST_MAX_EXTENSION];		/*!< Bridged channel name */
 	char bridgeduniqueid[AST_MAX_EXTENSION];	/*!< Bridged 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 */
-	char writetranslator[80];	/* Translation done on writing audio to PBX - bridged channel */
 	int writecost;			/* Delay in milliseconds for translation of 1 second of audio */
 };
 
@@ -2403,6 +2403,19 @@
 	ast_log(LOG_DEBUG, "--- Copied CNAME %s to RTCP structure (length %d)\n", cname, (int) length);
 }
 
+/*! \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)
+{
+	if (!rtp || !rtp->rtcp) {
+		return;
+	}
+	ast_copy_string(rtp->rtcp->readtranslator, readtranslator, sizeof(rtp->rtcp->readtranslator));
+	ast_copy_string(rtp->rtcp->writetranslator, writetranslator, sizeof(rtp->rtcp->writetranslator));
+	rtp->rtcp->readcost = readcost;
+	rtp->rtcp->writecost = writecost;
+	
+}
+
 /*! \brief set the name of the bridged channel
 
 At the time when we write the report there might not be a bridge, so we need
@@ -2566,7 +2579,6 @@
 	*txcount       transmitted packets
 	*rlp           remote lost packets
 	*rtt           round trip time
-
 	*/
 
 	if (qual && rtp) {
@@ -2596,6 +2608,14 @@
 			}
 			if (!ast_strlen_zero(rtp->rtcp->bridgeduniqueid)) {
 				ast_copy_string(qual->bridgeduniqueid, rtp->rtcp->bridgeduniqueid, sizeof(qual->bridgeduniqueid));
+			}
+			qual->readcost = rtp->rtcp->readcost;
+			qual->writecost = rtp->rtcp->writecost;
+			if (!ast_strlen_zero(rtp->rtcp->readtranslator)) {
+				ast_copy_string(qual->readtranslator, rtp->rtcp->readtranslator, sizeof(qual->readtranslator));
+			}
+			if (!ast_strlen_zero(rtp->rtcp->writetranslator)) {
+				ast_copy_string(qual->writetranslator, rtp->rtcp->writetranslator, sizeof(qual->writetranslator));
 			}
 		}
 	}




More information about the svn-commits mailing list