[asterisk-commits] oej: branch oej/pinefrog-rtcp-1.8 r382572 - in /team/oej/pinefrog-rtcp-1.8: c...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 7 08:21:53 CST 2013
Author: oej
Date: Thu Mar 7 08:21:46 2013
New Revision: 382572
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382572
Log:
What a wonderful feeling. It actually compiles.
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/rtcp.h
team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h
team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c
team/oej/pinefrog-rtcp-1.8/include/asterisk/logger.h
team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h
team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c
team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c
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=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/chan_sip.c Thu Mar 7 08:21:46 2013
@@ -671,14 +671,6 @@
{ 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
configuring devices
@@ -6904,7 +6896,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);
+ start_rtcp_events(p, sched);
}
sip_pvt_unlock(p);
return res;
@@ -8130,6 +8122,7 @@
set_socket_transport(&p->socket, SIP_TRANSPORT_UDP);
}
+ p->sip_cfg = &sip_cfg;
p->socket.fd = -1;
p->method = intended_method;
p->rtcpeventid = -1;
@@ -8196,10 +8189,10 @@
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));
+ ast_rtp_instance_setcname(p->rtp, p->callid, strlen(p->callid));
}
if (p->vrtp) {
- ast_rtcp_setcname(p->vrtp, p->callid, strlen(p->callid));
+ ast_rtp_instance_setcname(p->vrtp, p->callid, strlen(p->callid));
}
ast_string_field_set(p, mohinterpret, default_mohinterpret);
ast_string_field_set(p, mohsuggest, default_mohsuggest);
@@ -18660,9 +18653,11 @@
{
int realtimepeers;
int realtimeregs;
+ int realtimertpqos;
char codec_buf[SIPBUFSIZE];
const char *msg; /* temporary msg pointer */
struct sip_auth_container *credentials;
+
switch (cmd) {
case CLI_INIT:
@@ -18680,6 +18675,7 @@
realtimepeers = ast_check_realtime("sippeers");
realtimeregs = ast_check_realtime("sipregs");
+ realtimertpqos = ast_check_realtime("rtpqos");
ast_mutex_lock(&authl_lock);
credentials = authl;
@@ -20702,7 +20698,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);
+ start_rtcp_events(p, sched);
break;
case 180: /* 180 Ringing */
@@ -21616,20 +21612,21 @@
}
}
-/*! \brief Immediately stop RTP, VRTP and UDPTL as applicable */
+/*! \brief Immediately stop RTP, VRTP, TEXT and UDPTL as applicable */
static void stop_media_flows(struct sip_pvt *p)
{
/* Immediately stop RTP, VRTP and UDPTL as applicable */
- if (p->rtp && ast_rtp_isactive(p->rtp)) {
+ if (p->rtp && !ast_rtp_instance_isactive(p->rtp)) {
ast_rtp_instance_stop(p->rtp);
sip_rtcp_report(p, p->rtp, SDP_AUDIO, TRUE);
}
- if (p->vrtp && ast_rtp_isactive(p->vrtp)) {
+ if (p->vrtp && !ast_rtp_instance_isactive(p->vrtp)) {
ast_rtp_instance_stop(p->vrtp);
sip_rtcp_report(p, p->vrtp, SDP_VIDEO, TRUE);
}
- if (p->trtp)
+ if (p->trtp && !ast_rtp_instance_isactive(p->trtp)) {
ast_rtp_instance_stop(p->trtp);
+ }
if (p->udptl)
ast_udptl_stop(p->udptl);
}
@@ -29311,11 +29308,11 @@
global_qualifyfreq = DEFAULT_QUALIFYFREQ;
}
} else if (!strcasecmp(v->name, "rtcpevents")) {
- global_rtcpevents = ast_true(v->value);
+ sip_cfg.rtcpevents = ast_true(v->value);
} else if (!strcasecmp(v->name, "rtcpeventtimer")) {
- if (sscanf(v->value, "%30d", &global_rtcptimer) != 1) {
+ if (sscanf(v->value, "%30d", &sip_cfg.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;
+ sip_cfg.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=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/dialplan_functions.c Thu Mar 7 08:21:46 2013
@@ -164,9 +164,11 @@
if (!ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf))) {
return -1;
}
+#ifdef OEJ
if (!ast_rtp_instance_get_qualdata(rtp, ???, &qos)) {
this_needs_some_love;
}
+#endif
ast_copy_string(buf, quality_buf, buflen);
return res;
Modified: 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=diff&rev=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/include/rtcp.h Thu Mar 7 08:21:46 2013
@@ -23,17 +23,23 @@
#include "asterisk.h"
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
#include "asterisk/utils.h"
+#include "asterisk/rtp_engine.h"
+#include "sip.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);
+int send_rtcp_events(const void *data);
+void start_rtcp_events(struct sip_pvt *dialog, struct sched_context *sched);
+/*
+# For 1.4:
+# static void sip_rtcp_report(struct sip_pvt *p, struct ast_rtp *rtp, enum media_type type, int reporttype);
+*/
+
+void sip_rtcp_report(struct sip_pvt *dialog, struct ast_rtp_instance *instance, enum media_type type, int reporttype);
+//void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_quality *qual);
+void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_instance_stats *qual);
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=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/include/sip.h Thu Mar 7 08:21:46 2013
@@ -1139,8 +1139,12 @@
* 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_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_rtp_instance_stats *audioqual; /*!< Audio: The latest quality report, for realtime storage */
+ struct ast_rtp_instance_stats *videoqual; /*!< Video: The latest quality report, for realtime storage */
+ struct sip_settings *sip_cfg; /*! Which sip_cfg is associated with this dialog */
+
struct ast_cc_config_params *cc_params;
struct sip_epa_entry *epa_entry;
int fromdomainport; /*!< Domain port to show in from field */
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=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c (original)
+++ team/oej/pinefrog-rtcp-1.8/channels/sip/rtcp.c Thu Mar 7 08:21:46 2013
@@ -30,6 +30,10 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
+#include "asterisk/manager.h"
+#include "asterisk/logger.h"
+#include "asterisk/translate.h"
+#include "include/sip.h"
#include "include/rtcp.h"
@@ -38,62 +42,70 @@
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)
+void sip_rtcp_report(struct sip_pvt *dialog, struct ast_rtp_instance *instance, enum media_type type, int reporttype)
{
- struct ast_rtp_quality *qual;
- char *rtpqstring = NULL;
- int qosrealtime = ast_check_realtime("rtpqos");
+ struct ast_rtp_instance_stats 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 (dialog && dialog->owner) {
+ struct ast_channel *bridgepeer = ast_bridged_channel(dialog->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_rtp_instance_set_bridged_chan(instance, dialog->owner->name, dialog->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);
+ ast_rtp_instance_set_bridged_chan(instance, dialog->owner->name, dialog->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) {
+ struct ast_channel *chan = dialog->owner;
+ const char *rtname = NULL, *wtname = NULL;
/* 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);
+ readtrans = (chan->readtrans != NULL);
+ writetrans = (chan->writetrans != NULL);
+ if (readtrans) {
+ rtname = chan->readtrans->t->name;
+ }
+ if (writetrans) {
+ wtname = chan->writetrans->t->name;
+ }
+ ast_rtp_instance_set_translator(instance, rtname, readtrans ? chan->readtrans->t->cost : (const int) 0,
+ wtname, writetrans ? chan->writetrans->t->cost : (const int) 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 (readtrans && dialog->owner->readtrans->t) {
+ ast_log(LOG_DEBUG, "--- Audio Read translator: %s Cost %d\n", dialog->owner->readtrans->t->name, dialog->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);
+ if (writetrans && dialog->owner->writetrans->t) {
+ ast_log(LOG_DEBUG, "--- Audio Write translator: %s Cost %d\n", dialog->owner->writetrans->t->name, dialog->owner->writetrans->t->cost);
}
}
}
}
- rtpqstring = ast_rtp_get_quality(rtp);
- qual = ast_rtp_get_qualdata(rtp);
- if (!qual) {
+ //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 (global_rtcpevents) {
+ if (dialog->sip_cfg->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 */
@@ -123,35 +135,35 @@
"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 : "",
+ dialog->owner ? dialog->owner->name : "",
+ dialog->owner ? dialog->owner->uniqueid : "",
+ 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),
+ dialog->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,
+ ast_getformatname(qual.lasttxformat),
+ ast_getformatname(qual.lastrxformat),
+ qual.local_ssrc,
+ qual.remote_ssrc,
+ qual.rtt,
+ qual.maxrtt,
+ qual.minrtt,
+ qual.rxjitter,
+ qual.txjitter,
+ qual.rxploss,
/* 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_txcount + qual.rxploss) > 0 ? (double) qual.rxploss / (qual.remote_txcount + qual.rxploss) * 100 : 0,
+ qual.txploss,
/* 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.rxcount + qual.txploss) > 0 ? (double) qual.txploss / qual.rxcount * 100 : 0,
+ qual.readtranslator, qual.readcost,
+ qual.writetranslator, qual.writecost
);
}
@@ -161,23 +173,23 @@
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 (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;
+ dialog->audioqual = ast_calloc(sizeof(struct ast_rtp_instance_stats), 1);
+ (* dialog->audioqual) = qual;
+ dialog->audioqual->end = ast_tvnow();
+ dialog->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();
+ dialog->videoqual = ast_calloc(sizeof(struct ast_rtp_instance_stats), 1);
+ (* dialog->videoqual) = qual;
+ dialog->videoqual->mediatype = type;
+ dialog->videoqual->end = ast_tvnow();
}
}
}
/*! \brief Write quality report to realtime storage */
-void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_quality *qual)
+void qos_write_realtime(struct sip_pvt *dialog, struct ast_rtp_instance_stats *qual)
{
unsigned int duration; /* Duration in secs */
char buf_duration[10], buf_lssrc[30], buf_rssrc[30];
@@ -201,24 +213,26 @@
}
/* Realtime is based on strings, so let's make strings */
- sprintf(localjitter, "%f", qual->local_jitter);
- sprintf(remotejitter, "%f", qual->remote_jitter);
+ sprintf(localjitter, "%f", qual->rxjitter);
+ sprintf(remotejitter, "%f", qual->txjitter);
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_rttmax, "%.0f", qual->maxrtt);
+ sprintf(buf_rttmin, "%.0f", qual->minrtt);
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",
+ sprintf(buf_inpacketloss, "%d", qual->rxploss);
+ sprintf(buf_outpacketloss, "%d", qual->txploss);
+ sprintf(buf_inpackets, "%d", 42); /* Silly value. Need to check this */
+ sprintf(buf_outpackets, "%d", 42);
+ //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",
qual->channel[0] ? qual->channel : "",
qual->uniqueid[0] ? qual->uniqueid : "",
qual->bridgedchan[0] ? qual->bridgedchan : "" ,
@@ -238,7 +252,6 @@
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 --",
@@ -267,27 +280,26 @@
"packetsent", buf_outpackets,
"packetreceived", buf_inpackets,
NULL);
-#endif
}
/*! \brief Send RTCP manager events */
-static int send_rtcp_events(const void *data)
+int send_rtcp_events(const void *data)
{
struct sip_pvt *dialog = (struct sip_pvt *) data;
- if (dialog->rtp && ast_rtp_isactive(dialog->rtp)) {
+ if (dialog->rtp && ast_rtp_instance_isactive(dialog->rtp)) {
sip_rtcp_report(dialog, dialog->rtp, SDP_AUDIO, FALSE);
}
- if (dialog->vrtp && ast_rtp_isactive(dialog->vrtp)) {
+ if (dialog->vrtp && ast_rtp_instance_isactive(dialog->vrtp)) {
sip_rtcp_report(dialog, dialog->vrtp, SDP_VIDEO, FALSE);
}
- return global_rtcptimer;
+ return (dialog->sip_cfg ? dialog->sip_cfg->rtcptimer : 0);
}
/*! \brief Activate RTCP events at start of call */
-static void start_rtcp_events(struct sip_pvt *dialog)
+void start_rtcp_events(struct sip_pvt *dialog, struct sched_context *sched)
{
- if (!global_rtcpevents || !global_rtcptimer) {
+ if (!dialog->sip_cfg->rtcpevents || !dialog->sip_cfg->rtcptimer) {
return;
}
/* Check if it's already active */
@@ -296,5 +308,5 @@
}
/*! \brief Schedule events */
- dialog->rtcpeventid = ast_sched_add(sched, global_rtcptimer * 1000, send_rtcp_events, dialog);
+ dialog->rtcpeventid = ast_sched_add(sched, dialog->sip_cfg->rtcptimer * 1000, send_rtcp_events, dialog);
}
Modified: team/oej/pinefrog-rtcp-1.8/include/asterisk/logger.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/include/asterisk/logger.h?view=diff&rev=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/include/asterisk/logger.h (original)
+++ team/oej/pinefrog-rtcp-1.8/include/asterisk/logger.h Thu Mar 7 08:21:46 2013
@@ -180,6 +180,17 @@
#undef AST_LOG_DTMF
#endif
#define AST_LOG_DTMF __LOG_DTMF, _A_
+
+#ifdef LOG_CQR
+#undef LOG_CQR
+#endif
+#define __LOG_CQR 7
+#define LOG_CQR __LOG_CQR, _A_
+
+#ifdef AST_LOG_CQR
+#undef AST_LOG_CQR
+#endif
+#define AST_LOG_CQR __LOG_CQR, _A_
#define NUMLOGLEVELS 32
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=382572&r1=382571&r2=382572
==============================================================================
--- 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 08:21:46 2013
@@ -74,6 +74,7 @@
#include "asterisk/netsock2.h"
#include "asterisk/sched.h"
#include "asterisk/res_srtp.h"
+#include "asterisk/channel.h"
/* Maximum number of payloads supported */
#define AST_RTP_MAX_PT 256
@@ -237,10 +238,12 @@
unsigned int txcount;
/*! Number of packets received */
unsigned int rxcount;
+
/*! Jitter on transmitted packets */
double txjitter;
/*! Jitter on received packets */
double rxjitter;
+
/*! Maximum jitter on remote side */
double remote_maxjitter;
/*! Minimum jitter on remote side */
@@ -291,6 +294,28 @@
unsigned int local_ssrc;
/*! Their SSRC */
unsigned int remote_ssrc;
+
+ /* --- Pinefrog additions */
+ /*! Remote: Number of packets transmitted */
+ unsigned int remote_txcount;
+ /*! Remote: Number of packets received */
+ unsigned int remote_rxcount;
+ 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 */
+ 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 us; /*!< The IP address used for media by our end */
+ struct timeval start; /*!< When the stream started */
+ struct timeval end; /*!< When the stream ended */
+ 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 */
+ int mediatype; /*! Type of media */
};
#define AST_RTP_STAT_SET(current_stat, combined, placement, value) \
@@ -377,6 +402,15 @@
format_t (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
/*! Callback to send CNG */
int (*sendcng)(struct ast_rtp_instance *instance, int level);
+ /*! Callback to check if a media stram is active */
+ int (*isactive)(struct ast_rtp_instance *instance);
+ /*! Callback to set CNAME in rtcp */
+ void (*setcname)(struct ast_rtp_instance *instance, const char *cname, size_t length);
+ /*! Callback to set information about bridged channel for CQR record */
+ void (*set_bridged_chan)(struct ast_rtp_instance *instance, const char *channel, const char *uniqueid, const char *bridgedchan, const char *bridgeduniqueid);
+ /*! Callback to set translation information for the CQR record */
+ void (*set_translator) (struct ast_rtp_instance *instance, const char *readtranslator, const int readcost, const char *writetranslator, const int writecost);
+ int (*rtcp_write_empty)(struct ast_rtp_instance *instance);
/*! Linked list information */
AST_RWLIST_ENTRY(ast_rtp_engine) entry;
};
@@ -1834,6 +1868,36 @@
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level);
/*!
+ * \brief Send empty RTCP report
+ *
+ * \param instance The RTP instance
+ * \param fd File descriptor to use
+ *
+ * \retval 0 Success
+ * \retval non-zero Failure
+ */
+int ast_rtcp_write_empty(struct ast_rtp_instance *instance);
+
+
+/*!
+ * \brief Check if RTP stream is active
+ *
+ * \param instance The RTP instance
+ *
+ * \retval 0 Active (success)
+ * \retval -1 Not supported by RTP engine, 1 Not active
+ */
+int ast_rtp_instance_isactive(struct ast_rtp_instance *instance);
+
+/*!
+ * \brief Set the name of the RTP session (used in RTCP)
+ * \param cname Session name (UTF 8 possible)
+ * \param length Name of string (needed for UTF 8 always)
+ *
+ */
+int ast_rtp_instance_setcname(struct ast_rtp_instance *instance, const char *cname, size_t length);
+
+/*!
* \brief Add or replace the SRTP policies for the given RTP instance
*
* \param instance the RTP instance
@@ -1854,6 +1918,22 @@
*/
struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance);
+/*!
+ * \brief set the channel information for the CQR records
+ *
+ * \retval 0 on success
+ * \retval -1 not implemented by RTP engine
+ */
+int ast_rtp_instance_set_bridged_chan(struct ast_rtp_instance *instance, const char *channel, const char *uniqueid, const char *bridgedchan, const char *bridgeduniqueid);
+
+/*!
+ * \brief set the channel translator information for the CQR records
+ *
+ * \retval 0 on success
+ * \retval -1 not implemented by RTP engine
+ */
+int ast_rtp_instance_set_translator(struct ast_rtp_instance *instance, const char *readtranslator, const int readcost, const char *writetranslator, const int writecost);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c?view=diff&rev=382572&r1=382571&r2=382572
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c (original)
+++ team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c Thu Mar 7 08:21:46 2013
@@ -829,6 +829,7 @@
return AST_BRIDGE_FAILED_NOWARN;
}
+ /* Now let go of the channel locks and be on our way */
ast_channel_unlock(c0);
ast_channel_unlock(c1);
@@ -836,6 +837,10 @@
instance1->bridged = instance0;
ast_poll_channel_add(c0, c1);
+
+ /* Kick the RTCP stream going by sending one empty stupid little packet */
+ ast_rtcp_write_empty(instance0);
+ ast_rtcp_write_empty(instance1);
/* Hop into a loop waiting for a frame from either channel */
cs[0] = c0;
@@ -1836,11 +1841,58 @@
return instance->srtp;
}
+int ast_rtp_instance_isactive(struct ast_rtp_instance *instance)
+{
+ if (instance->engine->isactive) {
+ return instance->engine->isactive(instance);
+ }
+
+ return -1;
+}
+
+int ast_rtcp_write_empty(struct ast_rtp_instance *instance)
+{
+ if (instance->engine->rtcp_write_empty) {
+ instance->engine->rtcp_write_empty(instance);
+ return 0;
+ }
+ return -1;
+}
+
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
{
if (instance->engine->sendcng) {
return instance->engine->sendcng(instance, level);
}
-
return -1;
}
+
+int ast_rtp_instance_setcname(struct ast_rtp_instance *instance, const char *cname, size_t length)
+{
+ if (instance->engine->setcname) {
+ instance->engine->setcname(instance, cname, length);
+ return 0;
+ }
+
+ return -1; /* Function does not exist */
+}
+
+int ast_rtp_instance_set_bridged_chan(struct ast_rtp_instance *instance, const char *channel, const char *uniqueid, const char *bridgedchan, const char *bridgeduniqueid)
+{
+ if (instance->engine->set_bridged_chan) {
+ instance->engine->set_bridged_chan(instance, channel, uniqueid, bridgedchan, bridgeduniqueid);
+ return 0;
+ }
+
+ return -1; /* Function does not exist */
+}
+
+int ast_rtp_instance_set_translator(struct ast_rtp_instance *instance, const char *readtranslator, const int readcost, const char *writetranslator, const int writecost)
+{
+ if (instance->engine->set_translator) {
+ instance->engine->set_translator(instance, readtranslator, readcost, writetranslator, writecost);
+ return 0;
+ }
+
+ return -1; /* Function does not exist */
+}
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=382572&r1=382571&r2=382572
==============================================================================
--- 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 08:21:46 2013
@@ -67,12 +67,31 @@
#define MINIMUM_RTP_PORT 1024 /*!< Minimum port number to accept */
#define MAXIMUM_RTP_PORT 65535 /*!< Maximum port number to accept */
-#define RTCP_PT_FUR 192
-#define RTCP_PT_SR 200
-#define RTCP_PT_RR 201
-#define RTCP_PT_SDES 202
-#define RTCP_PT_BYE 203
-#define RTCP_PT_APP 204
+#define RTCP_PT_FUR 192 /*!< FIR - Full Intra-frame request (h.261) */
+#define RTCP_PT_NACK 193 /*!< NACK - Negative acknowledgement (h.261) */
+#define RTCP_PT_IJ 195 /*!< IJ - RFC 5450 Extended Inter-arrival jitter report */
+#define RTCP_PT_SR 200 /*!< SR - RFC 3550 Sender report */
+#define RTCP_PT_RR 201 /*!< RR - RFC 3550 Receiver report */
+#define RTCP_PT_SDES 202 /*!< SDES - Source Description */
+#define RTCP_PT_BYE 203 /*!< BYE - Goodbye */
+#define RTCP_PT_APP 204 /*!< APP - Application defined */
+#define RTCP_PT_RTPFB 205 /*!< RTPFB - Generic RTP feedback RFC 4585 */
+#define RTCP_PT_PSFB 206 /*!< PSFB - Payload specific data RFC 4585 */
+#define RTCP_PT_XR 207 /*!< XR - Extended report - RFC3611 */
+
+/*! \brief RFC 3550 RTCP SDES Item types */
+enum rtcp_sdes {
+ SDES_END = 0, /*!< End of SDES list */
+ SDES_CNAME = 1, /*!< Canonical name */
+ SDES_NAME = 2, /*!< User name */
+ SDES_EMAIL = 3, /*!< User's e-mail address */
+ SDES_PHONE = 4, /*!< User's phone number */
+ SDES_LOC = 5, /*!< Geographic user location */
+ SDES_TOOL = 6, /*!< Name of application or tool */
+ SDES_NOTE = 7, /*!< Notice about the source */
+ SDES_PRIV = 8, /*!< SDES Private extensions */
+ SDES_H323_CADDR = 9, /*!< H.323 Callable address */
+};
#define RTP_MTU 1200
@@ -168,10 +187,12 @@
struct timeval dtmfmute;
struct ast_smoother *smoother;
int *ioid;
+ int *ioidrtcp;
unsigned short seqno; /*!< Sequence number, RFC 3550, page 13. */
unsigned short rxseqno;
struct sched_context *sched;
struct io_context *io;
+ struct io_context *iortcp; /*!< for RTCP callback */
void *data;
struct ast_rtcp *rtcp;
struct ast_rtp *bridged; /*!< Who we are Packet bridged to */
@@ -186,6 +207,7 @@
*/
uint16_t learning_max_seq; /*!< Highest sequence number heard */
int learning_probation; /*!< Sequential packets untill source is valid */
+ int isactive; /*!< Whether the RTP stream is active or not */
struct rtp_red *red;
};
@@ -197,11 +219,18 @@
* this structure is analogous to ast_rtp, which tracks a RTP session,
* it is logical to think of this as a RTCP session.
*
+ * On the other hand, RTCP SDES defines the names for the actual
+ * RTP session so it's one session - RTP and RTCP together (OEJ)
+ *
* RTCP packet is defined on page 9 of RFC 3550.
*
*/
struct ast_rtcp {
int rtcp_info;
+ 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) */
int s; /*!< Socket */
struct ast_sockaddr us; /*!< Socket representation of the local endpoint. */
struct ast_sockaddr them; /*!< Socket representation of the remote endpoint. */
@@ -215,17 +244,19 @@
int schedid; /*!< Schedid returned from ast_sched_add() to schedule RTCP-transmissions*/
unsigned int rr_count; /*!< number of RRs we've sent, not including report blocks in SR's */
unsigned int sr_count; /*!< number of SRs we've sent */
+ unsigned int rec_rr_count; /*!< Number of RRs we've received */
+ unsigned int rec_sr_count; /*!< Number of SRs we've received */
unsigned int lastsrtxcount; /*!< Transmit packet count when last SR sent */
double accumulated_transit; /*!< accumulated a-dlsr-lsr */
double rtt; /*!< Last reported rtt */
unsigned int reported_jitter; /*!< The contents of their last jitter entry in the RR */
unsigned int reported_lost; /*!< Reported lost packets in their RR */
- double reported_maxjitter;
- double reported_minjitter;
+ double reported_maxjitter; /*!< The contents of their max jitter entry received by us */
+ double reported_minjitter; /*!< The contents of their min jitter entry received by us */
double reported_normdev_jitter;
double reported_stdev_jitter;
- unsigned int reported_jitter_count;
+ unsigned int reported_jitter_count; /*! Number of reports received */
double reported_maxlost;
double reported_minlost;
@@ -237,25 +268,33 @@
double minrxlost;
double normdev_rxlost;
double stdev_rxlost;
- unsigned int rxlost_count;
+ unsigned int rxlost_count; /*! Number of reports received */
double maxrxjitter;
double minrxjitter;
double normdev_rxjitter;
double stdev_rxjitter;
- unsigned int rxjitter_count;
+ unsigned int rxjitter_count; /*! Number of reports received */
double maxrtt;
double minrtt;
double normdevrtt;
double stdevrtt;
- unsigned int rtt_count;
+ unsigned int rtt_count; /*! Number of reports received */
+ 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 */
+ int writecost; /* Delay in milliseconds for translation of 1 second of audio */
};
struct rtp_red {
struct ast_frame t140; /*!< Primary data */
struct ast_frame t140red; /*!< Redundant t140*/
unsigned char pt[AST_RED_MAX_GENERATION]; /*!< Payload types for redundancy data */
- unsigned char ts[AST_RED_MAX_GENERATION]; /*!< Time stamps */
+unsigned char ts[AST_RED_MAX_GENERATION]; /*!< Time stamps */
unsigned char len[AST_RED_MAX_GENERATION]; /*!< length of each generation */
int num_gen; /*!< Number of generations */
int schedid; /*!< Timer id */
@@ -293,6 +332,14 @@
static void ast_rtp_stop(struct ast_rtp_instance *instance);
static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos, const char* desc);
static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level);
+static int ast_rtcp_write(const void *data);
+static void ast_rtcp_setcname(struct ast_rtp_instance *instance, const char *cname, size_t length);
+static void ast_rtcp_set_bridged(struct ast_rtp_instance *instance, const char *channel, const char *uniqueid, const char *bridgedchan, const char *bridgeduniqueid);
+void ast_rtcp_set_translator(struct ast_rtp_instance *instance, const char *readtranslator, const int readcost, const char *writetranslator, const int writecost);
+static int ast_rtp_isactive(struct ast_rtp_instance *instance);
+static int add_sdes_bodypart(struct ast_rtp *rtp, unsigned int *rtcp_packet, int len, int type);
+static int add_sdes_header(struct ast_rtp *rtp, unsigned int *rtcp_packet, int len);
+static int ast_rtcp_write_empty_frame(struct ast_rtp_instance *instance);
/* RTP Engine Declaration */
static struct ast_rtp_engine asterisk_rtp_engine = {
@@ -321,6 +368,11 @@
.stop = ast_rtp_stop,
.qos = ast_rtp_qos_set,
.sendcng = ast_rtp_sendcng,
+ .setcname = ast_rtcp_setcname,
+ .set_bridged_chan = ast_rtcp_set_bridged,
+ .set_translator = ast_rtcp_set_translator,
+ .isactive = ast_rtp_isactive,
+ .rtcp_write_empty = ast_rtcp_write_empty_frame,
};
static inline int rtp_debug_test_addr(struct ast_sockaddr *addr)
@@ -419,6 +471,23 @@
* Look in RFC 3550 Section A.7 for an example*/
interval = rtcpinterval;
return interval;
+}
+
+/*! \brief Schedule RTCP transmissions for RTP channel */
+static void ast_rtcp_schedule(struct ast_rtp_instance *instance)
+{
+ struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+
+ /* 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 */
+ 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) {
+ ao2_ref(instance, -1);
+ ast_log(LOG_WARNING, "scheduling RTCP transmission failed.\n");
+ }
+ }
}
/*! \brief Calculate normal deviation */
@@ -890,7 +959,7 @@
}
/*! \brief Send RTCP recipient's report */
-static int ast_rtcp_write_rr(struct ast_rtp_instance *instance)
+static int ast_rtcp_write_rr(struct ast_rtp_instance *instance, int goodbye)
{
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
int res;
@@ -902,7 +971,7 @@
unsigned int received_interval;
int lost_interval;
struct timeval now;
- unsigned int *rtcpheader;
+ unsigned int *rtcpheader, *start;
char bdata[1024];
struct timeval dlsr;
int fraction;
@@ -950,7 +1019,7 @@
fraction = (lost_interval << 8) / expected_interval;
gettimeofday(&now, NULL);
timersub(&now, &rtp->rtcp->rxlsr, &dlsr);
- rtcpheader = (unsigned int *)bdata;
+ rtcpheader = (unsigned int *) bdata;
rtcpheader[0] = htonl((2 << 30) | (1 << 24) | (RTCP_PT_RR << 16) | ((len/4)-1));
rtcpheader[1] = htonl(rtp->ssrc);
rtcpheader[2] = htonl(rtp->themssrc);
@@ -960,13 +1029,13 @@
rtcpheader[6] = htonl(rtp->rtcp->themrxlsr);
rtcpheader[7] = htonl((((dlsr.tv_sec * 1000) + (dlsr.tv_usec / 1000)) * 65536) / 1000);
- /*! \note Insert SDES here. Probably should make SDES text equal to mimetypes[code].type (not subtype 'cos
- it can change mid call, and SDES can't) */
- rtcpheader[len/4] = htonl((2 << 30) | (1 << 24) | (RTCP_PT_SDES << 16) | 2);
- rtcpheader[(len/4)+1] = htonl(rtp->ssrc); /* Our SSRC */
[... 792 lines stripped ...]
More information about the asterisk-commits
mailing list