aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2011-06-14 17:03:37 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2011-06-14 17:03:37 +0000
commitbdb71463e76f5a849c8805acb3037402219dbbb3 (patch)
tree9656c5e9abe9c471c0e64801869675d13c4a603e /res
parente2271ffc337b97e49cbdf0b8f8737563eafeb0f6 (diff)
Merged revisions 323370 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r323370 | twilson | 2011-06-14 09:33:55 -0700 (Tue, 14 Jun 2011) | 10 lines Add rtpkeepalives back to 1.8 The RTP-engine conversion left out support for handling rtpkeepalives. This patch adds them back. (closes issue ASTERISK-17304) Reported by: lmadsen Review: https://reviewboard.asterisk.org/r/1226/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@323374 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_rtp_asterisk.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index dd71342d1..60f7edacf 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -272,6 +272,7 @@ static int ast_rtp_dtmf_compatible(struct ast_channel *chan0, struct ast_rtp_ins
static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
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);
/* RTP Engine Declaration */
static struct ast_rtp_engine asterisk_rtp_engine = {
@@ -297,6 +298,7 @@ static struct ast_rtp_engine asterisk_rtp_engine = {
.stun_request = ast_rtp_stun_request,
.stop = ast_rtp_stop,
.qos = ast_rtp_qos_set,
+ .sendcng = ast_rtp_sendcng,
};
static inline int rtp_debug_test_addr(struct ast_sockaddr *addr)
@@ -2591,6 +2593,49 @@ static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos,
return ast_set_qos(rtp->s, tos, cos, desc);
}
+/*! \brief generate comfort noice (CNG) */
+static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
+{
+ unsigned int *rtpheader;
+ int hdrlen = 12;
+ int res;
+ int payload;
+ char data[256];
+ struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+ struct ast_sockaddr remote_address = { {0,} };
+
+ ast_rtp_instance_get_remote_address(instance, &remote_address);
+
+ if (ast_sockaddr_isnull(&remote_address)) {
+ return -1;
+ }
+
+ payload = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 0, NULL, AST_RTP_CN);
+
+ level = 127 - (level & 0x7f);
+
+ rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
+
+ /* Get a pointer to the header */
+ rtpheader = (unsigned int *)data;
+ rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload << 16) | (rtp->seqno++));
+ rtpheader[1] = htonl(rtp->lastts);
+ rtpheader[2] = htonl(rtp->ssrc);
+ data[12] = level;
+
+ res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 1, 0, &remote_address);
+
+ if (res < 0) {
+ ast_log(LOG_ERROR, "RTP Comfort Noise Transmission error to %s: %s\n", ast_sockaddr_stringify(&remote_address), strerror(errno));
+ } else if (rtp_debug_test_addr(&remote_address)) {
+ ast_verbose("Sent Comfort Noise RTP packet to %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+ ast_sockaddr_stringify(&remote_address),
+ AST_RTP_CN, rtp->seqno, rtp->lastdigitts, res - hdrlen);
+ }
+
+ return res;
+}
+
static char *rtp_do_debug_ip(struct ast_cli_args *a)
{
char *arg = ast_strdupa(a->argv[4]);