[asterisk-commits] oej: branch oej/pinefrog-rtcp-1.8 r382462 - in /team/oej/pinefrog-rtcp-1.8/ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 5 10:19:24 CST 2013


Author: oej
Date: Tue Mar  5 10:19:20 2013
New Revision: 382462

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382462
Log:
Look pa, this is just a bunch of patches that fails to compile. 

Added:
    team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h   (with props)
    team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c   (with props)
Modified:
    team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c
    team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c
    team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h

Modified: team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c?view=diff&rev=382462&r1=382461&r2=382462
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c Tue Mar  5 10:19:20 2013
@@ -275,6 +275,7 @@
 #include "asterisk/xml.h"
 #include "sip/include/dialog.h"
 #include "sip/include/dialplan_functions.h"
+#include "sip/include/rtcp.h"
 
 
 /*** DOCUMENTATION
@@ -670,6 +671,13 @@
 	{ AST_REDIRECTING_REASON_CALL_FWD_DTE, "unknown"}
 };
 
+/*! Media types for declaration of RTP streams */
+enum media_type {
+	SDP_AUDIO,	/* AUDIO class */
+	SDP_VIDEO,
+	SDP_IMAGE,
+/* For later versions that 1.4 we need to add SDP_TEXT for T.140 */
+};
 
 /*! \name DefaultSettings
 	Default setttings are used as a channel setting and as a default when
@@ -6163,6 +6171,22 @@
 
 	if (dumphistory)
 		sip_dump_history(p);
+
+	AST_SCHED_DEL(sched, p->rtcpeventid);
+
+ 	if (p->audioqual) {
+ 		/* We have a quality report to write to realtime before we leave this world. */
+ 		qos_write_realtime(p, p->audioqual);
+ 		free(p->audioqual);
+ 		p->audioqual = NULL;
+ 	}
+ 	if (p->videoqual) {
+ 		/* We have a quality report to write to realtime before we leave this world. */
+ 		qos_write_realtime(p, p->videoqual);
+ 		free(p->videoqual);
+ 		p->videoqual = NULL;
+ 	}
+
 
 	if (p->options) {
 		if (p->options->outboundproxy) {
@@ -6880,6 +6904,7 @@
 		ast_rtp_instance_update_source(p->rtp);
 		res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL, FALSE, TRUE);
 		ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
+		start_rtcp_events(p);
 	}
 	sip_pvt_unlock(p);
 	return res;
@@ -8107,6 +8132,7 @@
 
 	p->socket.fd = -1;
 	p->method = intended_method;
+	p->rtcpeventid = -1;
 	p->initid = -1;
 	p->waitid = -1;
 	p->reinviteid = -1;
@@ -8169,6 +8195,12 @@
 	else
 		ast_string_field_set(p, callid, callid);
 	/* Assign default music on hold class */
+	if (p->rtp) {
+		ast_rtcp_setcname(p->rtp, p->callid, strlen(p->callid));
+	}
+	if (p->vrtp) {
+		ast_rtcp_setcname(p->vrtp, p->callid, strlen(p->callid));
+	}
 	ast_string_field_set(p, mohinterpret, default_mohinterpret);
 	ast_string_field_set(p, mohsuggest, default_mohsuggest);
 	p->capability = sip_cfg.capability;
@@ -18010,8 +18042,10 @@
 	int x = 0, load_realtime;
 	format_t codec = 0;
 	int realtimepeers;
+	int realtimertpqos = FALSE;
 
 	realtimepeers = ast_check_realtime("sippeers");
+	realtimertpqos = ast_check_realtime("rtpqos");
 
 	if (argc < 4)
 		return CLI_SHOWUSAGE;
@@ -18715,6 +18749,8 @@
 	}
 	ast_cli(a->fd, "  Record SIP history:     %s\n", AST_CLI_ONOFF(recordhistory));
 	ast_cli(a->fd, "  Call Events:            %s\n", AST_CLI_ONOFF(sip_cfg.callevents));
+	ast_cli(a->fd, "  RTCP Events:            %s\n", AST_CLI_ONOFF(sip_cfg.rtcpevents));
+	ast_cli(a->fd, "  RTCP Event timer:       %d\n", sip_cfg.rtcptimer);
 	ast_cli(a->fd, "  Auth. Failure Events:   %s\n", AST_CLI_ONOFF(global_authfailureevents));
 
 	ast_cli(a->fd, "  T.38 support:           %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT)));
@@ -18724,6 +18760,7 @@
 		ast_cli(a->fd, "  SIP realtime:           Disabled\n" );
 	else
 		ast_cli(a->fd, "  SIP realtime:           Enabled\n" );
+	ast_cli(a->fd, "  QOS realtime reports:   %s\n", realtimertpqos ? "Enabled" : "Disabled" );
 	ast_cli(a->fd, "  Qualify Freq :          %d ms\n", global_qualifyfreq);
 	ast_cli(a->fd, "  Q.850 Reason header:    %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_PAGE2_Q850_REASON)));
 	ast_cli(a->fd, "  Store SIP_CAUSE:        %s\n", AST_CLI_YESNO(global_store_sip_cause));
@@ -20665,6 +20702,7 @@
 		if (!req->ignore && p->invitestate != INV_CANCELLED && sip_cancel_destroy(p))
 			ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
 		check_pendings(p);
+		start_rtcp_events(p);
 		break;
 
 	case 180:	/* 180 Ringing */
@@ -21582,10 +21620,14 @@
 static void stop_media_flows(struct sip_pvt *p)
 {
 	/* Immediately stop RTP, VRTP and UDPTL as applicable */
-	if (p->rtp)
+	if (p->rtp && ast_rtp_isactive(p->rtp)) {
 		ast_rtp_instance_stop(p->rtp);
-	if (p->vrtp)
+		sip_rtcp_report(p, p->rtp, SDP_AUDIO, TRUE);
+	}
+	if (p->vrtp && ast_rtp_isactive(p->vrtp)) {
 		ast_rtp_instance_stop(p->vrtp);
+		sip_rtcp_report(p, p->vrtp, SDP_VIDEO, TRUE);
+	}
 	if (p->trtp)
 		ast_rtp_instance_stop(p->trtp);
 	if (p->udptl)
@@ -28844,6 +28886,8 @@
 	/* Misc settings for the channel */
 	global_relaxdtmf = FALSE;
 	sip_cfg.callevents = DEFAULT_CALLEVENTS;
+	sip_cfg.rtcpevents = FALSE;
+	sip_cfg.rtcptimer = 0;	/* Only report at end of call (default) */
 	global_authfailureevents = FALSE;
 	global_t1 = DEFAULT_TIMER_T1;
 	global_timer_b = 64 * DEFAULT_TIMER_T1;
@@ -29265,6 +29309,13 @@
 			} else {
 				ast_log(LOG_WARNING, "Invalid qualifyfreq number '%s' at line %d of %s\n", v->value, v->lineno, config);
 				global_qualifyfreq = DEFAULT_QUALIFYFREQ;
+			}
+		} else if (!strcasecmp(v->name, "rtcpevents")) {
+			global_rtcpevents = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "rtcpeventtimer")) {
+			if (sscanf(v->value, "%30d", &global_rtcptimer) != 1) {
+				ast_log(LOG_WARNING, "RTCP event timer needs to be value (seconds between reports) at line %d of sip.conf\n", v->lineno);
+				global_rtcptimer = 0;
 			}
 		} else if (!strcasecmp(v->name, "callevents")) {
 			sip_cfg.callevents = ast_true(v->value);

Modified: team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c?view=diff&rev=382462&r1=382461&r2=382462
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c Tue Mar  5 10:19:20 2013
@@ -140,7 +140,9 @@
 
 		snprintf(buf, buflen, "%s", ast_sockaddr_stringify(&sa));
 	} else if (!strcasecmp(args.param, "rtpqos")) {
+/* OEJ - Check this part, different from 1.4 */
 		struct ast_rtp_instance *rtp = NULL;
+		struct ast_rtp_quality *qos;
 
 		if (ast_strlen_zero(args.type)) {
 			args.type = "audio";
@@ -161,6 +163,9 @@
 
 			if (!ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf))) {
 				return -1;
+			}
+			if (!ast_rtp_instance_get_qualdata(rtp, ???, &qos)) {
+				this_needs_some_love;
 			}
 
 			ast_copy_string(buf, quality_buf, buflen);

Added: team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h?view=auto&rev=382462
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h (added)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h Tue Mar  5 10:19:20 2013
@@ -1,0 +1,40 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013 Olle E. Johansson, Edvina AB
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file rtcp.h
+ *
+ * \brief RTCP additional functions
+ *
+ * \author Olle E. Johansson <oej at edvina.net>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/utils.h"
+
+#ifndef _SIP_RTCP_H
+#define _SIP_RTCP_H
+
+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 qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_quality *qual);
+
+
+
+#endif /* _SIP_RTCP_H */

Propchange: team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h?view=diff&rev=382462&r1=382461&r2=382462
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h Tue Mar  5 10:19:20 2013
@@ -697,6 +697,8 @@
 	int compactheaders;         /*!< send compact sip headers */
 	int allow_external_domains; /*!< Accept calls to external SIP domains? */
 	int callevents;             /*!< Whether we send manager events or not */
+	int rtcpevents;             /*!< Whether we send manager RTCP events or not */
+	int rtcptimer;		    /*!< How often, during a call, to report RTCP stats */
 	int regextenonqualify;      /*!< Whether to add/remove regexten when qualifying peers */
 	int legacy_useroption_parsing; /*!< Whether to strip useroptions in URI via semicolons */
 	int matchexternaddrlocally;   /*!< Match externaddr/externhost setting against localnet setting */
@@ -1081,6 +1083,7 @@
 	int waitid;                         /*!< Wait ID for scheduler after 491 or other delays */
 	int reinviteid;                     /*!< Reinvite in case of provisional, but no final response */
 	int autokillid;                     /*!< Auto-kill ID (scheduler) */
+	int rtcpeventid;                        /*!< Scheduler ID for RTCP Events */
 	int t38id;                          /*!< T.38 Response ID */
 	struct sip_refer *refer;            /*!< REFER: SIP transfer data structure */
 	enum subscriptiontype subscribed;   /*!< SUBSCRIBE: Is this dialog a subscription?  */
@@ -1136,6 +1139,8 @@
 	 * The large-scale changes would be a good idea for implementing during an SDP rewrite.
 	 */
 	struct offered_media offered_media[OFFERED_MEDIA_COUNT];
+	struct ast_rtp_quality *audioqual;              /*!< Audio: The latest quality report, for realtime storage */
+	 struct ast_rtp_quality *videoqual;              /*!< Video: The latest quality report, for realtime storage */
 	struct ast_cc_config_params *cc_params;
 	struct sip_epa_entry *epa_entry;
 	int fromdomainport;                 /*!< Domain port to show in from field */

Added: 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=auto&rev=382462
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c (added)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c Tue Mar  5 10:19:20 2013
@@ -1,0 +1,300 @@
+/*
+* Asterisk -- An open source telephony toolkit.
+*
+* Copyright (C) 2013 Olle E. Johansson, Edvina AB
+*
+* See http://www.asterisk.org for more information about
+* the Asterisk project. Please do not directly contact
+* any of the maintainers of this project for assistance;
+* the project provides a web site, mailing lists and IRC
+* channels for your use.
+*
+* This program is free software, distributed under the terms of
+* the GNU General Public License Version 2. See the LICENSE file
+* at the top of the source tree.
+*/
+
+/*! \file rtcp.c
+*
+* \brief RTCP additional functions
+*
+* \author Olle E. Johansson <oej at edvina.net>
+*/
+
+/*** MODULEINFO
+	<support_level>core</support_level>
+***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/utils.h"
+#include "include/rtcp.h"
+
+
+/*! \brief send manager report of RTCP 
+	reporttype = 0  means report during call (if configured)
+	reporttype = 1  means endof-call (hangup) report
+	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)
+{
+	struct ast_rtp_quality *qual;
+	char *rtpqstring = NULL;
+	int qosrealtime = ast_check_realtime("rtpqos");
+	unsigned int duration;	/* Duration in secs */
+ 	int readtrans = FALSE, writetrans = FALSE;
+
+	memset(&qual, sizeof(qual), 0);
+  
+	if (p && p->owner) {
+		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, 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 */
+		/* 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, "--- 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, "--- Audio Write translator: %s Cost %d\n", p->owner->writetrans->t->name, p->owner->writetrans->t->cost);
+ 				}
+			}
+		}
+
+	}
+
+	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);
+		manager_event(EVENT_FLAG_CALL, "RTPQuality", 
+			"Channel: %s\r\n"			/* AST_CHANNEL for this call */
+			"Uniqueid: %s\r\n"			/* AST_CHANNEL for this call */
+			"BridgedChannel: %s\r\n"
+			"BridgedUniqueid: %s\r\n"
+			"RTPreporttype: %s\r\n"
+			"RTPrtcpstatus: %s\r\n"
+			"Duration: %u\r\n"		/* used in cdr_manager */
+			"PvtCallid: %s\r\n"		/* ??? Generic PVT identifier */
+			"RTPipaddress: %s\r\n"
+			"RTPmedia: %s\r\n"		/* Audio, video, text */
+			"RTPsendformat: %s\r\n"
+			"RTPrecvformat: %s\r\n"
+			"RTPlocalssrc: %u\r\n"
+			"RTPremotessrc: %u\r\n"
+			"RTPrtt: %f\r\n"
+			"RTPrttMax: %f\r\n"
+			"RTPrttMin: %f\r\n"
+			"RTPLocalJitter: %f\r\n"
+			"RTPRemoteJitter: %f\r\n" 
+			"RTPInPacketLoss: %d\r\n" 
+			"RTPInLocalPlPercent: %5.2f\r\n"
+			"RTPOutPacketLoss: %d\r\n"
+			"RTPOutPlPercent: %5.2f\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 : "",
+			qual->bridgedchan[0] ? qual->bridgedchan : "" ,
+			qual->bridgeduniqueid[0] ? qual->bridgeduniqueid : "",
+			reporttype == 1 ? "Final" : "Update",
+			qual->numberofreports == 0 ? "Inactive" : "Active",
+			duration,
+			p->callid, 
+			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,
+			/* 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,
+			/* 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
+		);
+	}
+
+	/* CDR records are not reliable when it comes to near-death-of-channel events, so we need to store the RTCP
+	   report in realtime when we have it.
+	   Tests have proven that storing to realtime from the call thread is NOT a good thing. Therefore, we just save
+	   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 {
+		if (type == SDP_AUDIO) {  /* Audio */
+			p->audioqual = ast_calloc(sizeof(struct ast_rtp_quality), 1);
+			(* p->audioqual) = *qual;
+			p->audioqual->end = ast_tvnow();
+ 			p->audioqual->mediatype = type;
+		} else if (type == SDP_VIDEO) {  /* Video */
+			p->videoqual = ast_calloc(sizeof(struct ast_rtp_quality), 1);
+			(* p->videoqual) = *qual;
+ 			p->videoqual->mediatype = type;
+			p->videoqual->end = ast_tvnow();
+		}
+	}
+}
+
+/*! \brief Write quality report to realtime storage */
+void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_quality *qual)
+{
+	unsigned int duration;	/* Duration in secs */
+	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];
+	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
+	   the RTP stream duration which may include early media (ringing and
+	   provider messages). Only useful for measurements.
+	 */
+	if (!ast_tvzero(qual->end)) {
+		duration = (unsigned int)(ast_tvdiff_ms(qual->end, qual->start) / 1000);
+	} else {
+		duration = 0;
+	}
+
+	/* Realtime is based on strings, so let's make strings */
+	sprintf(localjitter, "%f", qual->local_jitter);
+	sprintf(remotejitter, "%f", qual->remote_jitter);
+	sprintf(buf_lssrc, "%u", qual->local_ssrc);
+	sprintf(buf_rssrc, "%u", qual->remote_ssrc);
+	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);
+	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_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 --",
+		"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, 
+		"rttmax", buf_rttmax, 
+		"rttmin", buf_rttmin, 
+		"localjitter", localjitter, 
+		"remotejitter", remotejitter, 
+		"sendformat", ast_getformatname(qual->lasttxformat),
+		"receiveformat", ast_getformatname(qual->lastrxformat),
+		"rtcpstatus", qual->numberofreports == 0 ? "Inactive" : "Active",
+		"duration", buf_duration,
+		"writetranslator", qual->writetranslator[0] ? qual->writetranslator : "",
+		"writecost", buf_writecost,
+		"readtranslator", qual->readtranslator[0] ? qual->readtranslator : "",
+		"readcost", buf_readcost,
+		"packetlossin", buf_inpacketloss,
+		"packetlossout", buf_outpacketloss,
+		"packetsent", buf_outpackets,
+		"packetreceived", buf_inpackets,
+		NULL);
+#endif
+}
+
+/*! \brief Send RTCP manager events */
+static int send_rtcp_events(const void *data)
+{
+	struct sip_pvt *dialog = (struct sip_pvt *) data;
+
+	if (dialog->rtp && ast_rtp_isactive(dialog->rtp)) {
+		sip_rtcp_report(dialog, dialog->rtp, SDP_AUDIO, FALSE);
+	}
+	if (dialog->vrtp && ast_rtp_isactive(dialog->vrtp)) {
+		sip_rtcp_report(dialog, dialog->vrtp, SDP_VIDEO, FALSE);
+	}
+	return global_rtcptimer;
+}
+
+/*! \brief Activate RTCP events at start of call */
+static void start_rtcp_events(struct sip_pvt *dialog)
+{
+	if (!global_rtcpevents || !global_rtcptimer) {
+		return;
+	}
+	/* Check if it's already active */
+	if (dialog->rtcpeventid != -1) {
+		return;
+	}
+
+	/*! \brief Schedule events */
+	dialog->rtcpeventid = ast_sched_add(sched, global_rtcptimer * 1000, send_rtcp_events, dialog);
+}

Propchange: team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list