[asterisk-commits] oej: branch oej/pinefrog-rtcp-1.8 r382632 - in /team/oej/pinefrog-rtcp-1.8: c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 7 13:35:52 CST 2013


Author: oej
Date: Thu Mar  7 13:35:48 2013
New Revision: 382632

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382632
Log:
The basics is there. Report data missing. Needs more tests. Many calls.

Modified:
    team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c
    team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h
    team/oej/pinefrog-rtcp-1.8/main/logger.c
    team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c

Modified: team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c?view=diff&rev=382632&r1=382631&r2=382632
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c Thu Mar  7 13:35:48 2013
@@ -33,6 +33,7 @@
 #include "asterisk/manager.h"
 #include "asterisk/logger.h"
 #include "asterisk/translate.h"
+#include "asterisk/rtp_engine.h"
 #include "include/sip.h"
 #include "include/rtcp.h"
 
@@ -49,6 +50,7 @@
 	//int qosrealtime = ast_check_realtime("rtpqos");
 	unsigned int duration;	/* Duration in secs */
  	int readtrans = FALSE, writetrans = FALSE;
+	memset(&qual, 0, sizeof(qual));
 	
 
 	if (dialog && dialog->owner) {
@@ -91,15 +93,8 @@
 
 	}
 
-	//rtpqstring =  ast_rtp_get_quality(instance);
 	if (ast_rtp_instance_get_stats(instance, &qual, AST_RTP_INSTANCE_STAT_ALL)) {
-	//qual = ast_rtp_get_qualdata(instance);
-	//if (!qual) {
 		/* Houston, we got a problem */
-		return;
-	}
-	if (!qual) {
-		ast_log(LOG_ERROR, "--- Got not CQR data from RTP. \n");
 		return;
 	}
 	
@@ -178,16 +173,15 @@
 	   monitor thread instead.
 	 */
 	if (reporttype == 1) {
+		ast_log(LOG_DEBUG, "---- Activation qual structure in dialog \n");
+		qual.end = ast_tvnow();
+ 		qual.mediatype = type;
 		if (type == SDP_AUDIO) {  /* Audio */
-			dialog->audioqual = ast_calloc(sizeof(struct ast_rtp_instance_stats), 1);
+			dialog->audioqual = ast_calloc(1, sizeof(struct ast_rtp_instance_stats));
 			(* dialog->audioqual) = qual;
-			dialog->audioqual->end = ast_tvnow();
- 			dialog->audioqual->mediatype = type;
 		} else if (type == SDP_VIDEO) {  /* Video */
-			dialog->videoqual = ast_calloc(sizeof(struct ast_rtp_instance_stats), 1);
+			dialog->videoqual = ast_calloc(1,sizeof(struct ast_rtp_instance_stats));
 			(* dialog->videoqual) = qual;
- 			dialog->videoqual->mediatype = type;
-			dialog->videoqual->end = ast_tvnow();
 		}
 	}
 }
@@ -204,6 +198,9 @@
 	char buf_remoteip[25];
 	char buf_inpacketloss[25], buf_outpacketloss[25];
 	char buf_outpackets[25], buf_inpackets[25];
+	int qosrealtime = ast_check_realtime("rtpqos");
+
+	ast_log(LOG_DEBUG, "************* QOS END REPORTS: The final countdown!!!!! Yeah. \n");
 
 	if (!qual) {
 		ast_log(LOG_ERROR, "No CQR data provided \n");
@@ -215,9 +212,10 @@
 	   the RTP stream duration which may include early media (ringing and
 	   provider messages). Only useful for measurements.
 	 */
-	if (!ast_tvzero(qual->end)) {
+	if (!ast_tvzero(qual->end) && !ast_tvzero(qual->start)) {
 		duration = (unsigned int)(ast_tvdiff_ms(qual->end, qual->start) / 1000);
 	} else {
+		ast_log(LOG_DEBUG, "**** WTF? No duration? What type of call is THAT? \n");
 		duration = 0;
 	}
 
@@ -241,7 +239,8 @@
 	//sprintf(buf_inpackets, "%d", qual->remote_count);	/* Do check again */
 	//sprintf(buf_outpackets, "%d", qual->local_count);
 
-	ast_log(LOG_CQR, "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",
+	ast_log(LOG_DEBUG, "************* QOS END REPORTS: Probing new logging channel LOG_CQR!!!!! Yeah. \n");
+	ast_log(LOG_DEBUG, "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 : "" ,
@@ -260,6 +259,10 @@
 		buf_outpacketloss,
 		buf_inpackets,
 		buf_inpacketloss);
+
+	if (!qosrealtime) {
+		return;
+	}
 
 	ast_store_realtime("rtpqos", 
 		"channel", qual->channel[0] ? qual->channel : "--no channel--",
@@ -295,6 +298,7 @@
 int send_rtcp_events(const void *data)
 {
 	struct sip_pvt *dialog = (struct sip_pvt *) data;
+	ast_log(LOG_DEBUG, "***** SENDING RTCP EVENT \n");
 
 	if (dialog->rtp && ast_rtp_instance_isactive(dialog->rtp)) {
 		sip_rtcp_report(dialog, dialog->rtp, SDP_AUDIO, FALSE);
@@ -308,6 +312,7 @@
 /*! \brief Activate RTCP events at start of call */
 void start_rtcp_events(struct sip_pvt *dialog, struct sched_context *sched)
 {
+	ast_log(LOG_DEBUG, "***** STARTING SENDING RTCP EVENT \n");
 	if (!dialog->sip_cfg->rtcpevents || !dialog->sip_cfg->rtcptimer) {
 		return;
 	}

Modified: team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h?view=diff&rev=382632&r1=382631&r2=382632
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h (original)
+++ team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h Thu Mar  7 13:35:48 2013
@@ -212,6 +212,14 @@
 	AST_RTP_INSTANCE_STAT_LOCAL_SSRC,
 	/*! Retrieve remote SSRC */
 	AST_RTP_INSTANCE_STAT_REMOTE_SSRC,
+	/*! Retrieve local CNAME */
+	AST_RTP_INSTANCE_STAT_LOCAL_CNAME,
+	/*! Retrieve remote SDES */
+	AST_RTP_INSTANCE_STAT_REMOTE_CNAME,
+	/*! Retrieve start time */
+	AST_RTP_INSTANCE_STAT_START,
+	/*! Retrieve IP Address */
+	AST_RTP_INSTANCE_STAT_IP,
 };
 
 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
@@ -309,6 +317,10 @@
 	int lastrxformat;		  /*!< Last used codec on received stream */
 	struct sockaddr_in them;	  /*!< The IP address used for media by remote end */
 	struct sockaddr_in us;	  	  /*!< The IP address used for media by our end */
+	char ourcname[255];		/*!< Our SDES RTP session name (CNAME) */
+	size_t ourcnamelength;		/*!< Length of CNAME (utf8) */
+	char theircname[255];		/*!< Their SDES RTP session name (CNAME) */
+	size_t theircnamelength;	/*!< Length of CNAME (utf8) */
 	struct timeval start;		  /*!< When the stream started */
 	struct timeval end;		  /*!< When the stream ended */
 	char writetranslator[80];	  /*!< Translator used when writing */

Modified: team/oej/pinefrog-rtcp-1.8/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/main/logger.c?view=diff&rev=382632&r1=382631&r2=382632
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/main/logger.c (original)
+++ team/oej/pinefrog-rtcp-1.8/main/logger.c Thu Mar  7 13:35:48 2013
@@ -174,6 +174,7 @@
 	"ERROR",
 	"VERBOSE",
 	"DTMF",
+	"CQR",
 };
 
 /*! \brief Colors used in the console for logging */

Modified: team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c?view=diff&rev=382632&r1=382631&r2=382632
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c (original)
+++ team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c Thu Mar  7 13:35:48 2013
@@ -183,6 +183,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;
@@ -481,6 +482,7 @@
 	/* Do not schedule RR if RTCP isn't run */
 	if (rtp->rtcp && !ast_sockaddr_isnull(&rtp->rtcp->them)  && rtp->rtcp->schedid < 1) {
 		/* Schedule transmission of Receiver Report */
+		ast_rtcp_write_empty(instance);
 		ao2_ref(instance, +1);
 		rtp->rtcp->schedid = ast_sched_add(rtp->sched, ast_rtcp_calc_interval(rtp), ast_rtcp_write, instance);
 		if (rtp->rtcp->schedid < 0) {
@@ -648,6 +650,9 @@
 
 	/* Associate the RTP structure with the RTP instance and be done */
 	ast_rtp_instance_set_data(instance, rtp);
+
+	gettimeofday(&rtp->start, NULL);
+	rtp->isactive = 1;
 
 	return 0;
 }
@@ -3003,6 +3008,30 @@
 	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_LOCAL_SSRC, -1, stats->local_ssrc, rtp->ssrc);
 	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_REMOTE_SSRC, -1, stats->remote_ssrc, rtp->themssrc);
 
+	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_START, -1, stats->start, rtp->start);
+	if (stat == AST_RTP_INSTANCE_STAT_IP || stat == AST_RTP_INSTANCE_STAT_ALL) {
+		memcpy(&stats->them, &rtp->rtcp->them, sizeof(stats->them));
+	}
+	if (stat == AST_RTP_INSTANCE_STAT_LOCAL_CNAME || stat == AST_RTP_INSTANCE_STAT_ALL) {
+		memcpy(&stats->ourcname, &rtp->rtcp->ourcname, rtp->rtcp->ourcnamelength);	/* UTF8 safe */
+		stats->ourcnamelength = rtp->rtcp->ourcnamelength;
+	}
+	if (stat == AST_RTP_INSTANCE_STAT_REMOTE_CNAME || stat == AST_RTP_INSTANCE_STAT_ALL) {
+		memcpy(&stats->theircname, &rtp->rtcp->theircname, rtp->rtcp->theircnamelength);	/* UTF8 safe */
+		stats->theircnamelength = rtp->rtcp->theircnamelength;
+	}
+
+	/* To fix */
+	stats->readcost = rtp->rtcp->readcost;
+        stats->writecost = rtp->rtcp->writecost;
+	stats->lasttxformat = rtp->lasttxformat;
+	stats->lastrxformat = rtp->lastrxformat;
+	if (!ast_strlen_zero(rtp->rtcp->readtranslator)) {
+		ast_copy_string(stats->readtranslator, rtp->rtcp->readtranslator, sizeof(stats->readtranslator));
+	}
+	if (!ast_strlen_zero(rtp->rtcp->writetranslator)) {
+		ast_copy_string(stats->writetranslator, rtp->rtcp->writetranslator, sizeof(stats->writetranslator));
+	}
 	return 0;
 }
 
@@ -3037,12 +3066,20 @@
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
 	struct ast_sockaddr addr = { {0,} };
 
+	ast_debug(1, "##### Stopping RTP, Sending good bye \n");
+
+	/* Send RTCP goodbye packet */
+	if (rtp->isactive && rtp->rtcp) {
+		ast_rtcp_write_sr(instance, 1);
+		ast_debug(1, "##### Stopping RTCP, Sent good bye \n");
+	}
 	if (rtp->rtcp && rtp->rtcp->schedid > 0) {
 		if (!ast_sched_del(rtp->sched, rtp->rtcp->schedid)) {
 			/* successfully cancelled scheduler entry. */
 			ao2_ref(instance, -1);
 		}
 		rtp->rtcp->schedid = -1;
+		ast_debug(1, "##### Stopping RTCP, Removing scheduler \n");
 	}
 
 	if (rtp->red) {
@@ -3057,6 +3094,7 @@
 	}
 
 	ast_set_flag(rtp, FLAG_NEED_MARKER_BIT);
+	rtp->isactive = 0;
 }
 
 static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
@@ -3187,7 +3225,7 @@
 static int ast_rtp_isactive(struct ast_rtp_instance *instance)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	return rtp->isactive;
+	return rtp->isactive ? 0 : 1;
 }
 
 /*! \brief Basically add SSRC */
@@ -3248,6 +3286,7 @@
 	if (!rtp || !rtp->rtcp) {
 		return 0;
 	} 
+	ast_debug(1,  "************ ---- About to send empty RTCP packet\n");
 	fd = rtp->rtcp->s;
 	
 	if (fd == -1) {




More information about the asterisk-commits mailing list