[Asterisk-cvs] asterisk rtp.c,1.104,1.105
markster at lists.digium.com
markster at lists.digium.com
Fri Jan 7 01:06:51 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv29875
Modified Files:
rtp.c
Log Message:
Support CNG transmission when on hold (bug #2904)
Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- rtp.c 28 Dec 2004 16:45:03 -0000 1.104
+++ rtp.c 7 Jan 2005 07:11:39 -0000 1.105
@@ -1129,6 +1129,46 @@
return 0;
}
+int ast_rtp_sendcng(struct ast_rtp *rtp, int level)
+{
+ unsigned int *rtpheader;
+ int hdrlen = 12;
+ int res;
+ int payload;
+ char data[256];
+ char iabuf[INET_ADDRSTRLEN];
+ level = 127 - (level & 0x7f);
+ payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_CN);
+
+ /* If we have no peer, return immediately */
+ if (!rtp->them.sin_addr.s_addr)
+ return 0;
+
+ gettimeofday(&rtp->dtmfmute, NULL);
+ rtp->dtmfmute.tv_usec += (500 * 1000);
+ if (rtp->dtmfmute.tv_usec > 1000000) {
+ rtp->dtmfmute.tv_usec -= 1000000;
+ rtp->dtmfmute.tv_sec += 1;
+ }
+
+ /* 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;
+ if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
+ res = sendto(rtp->s, (void *)rtpheader, hdrlen + 1, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
+ if (res <0)
+ ast_log(LOG_ERROR, "RTP Comfort Noise Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
+ if(rtp_debug_test_addr(&rtp->them))
+ ast_verbose("Sent Comfort Noise RTP packet to %s:%d (type %d, seq %d, ts %d, len %d)\n"
+ , ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastts,res - hdrlen);
+
+ }
+ return 0;
+}
+
#ifdef SOLARIS
static void put_uint32(unsigned char *buf, int i)
{
More information about the svn-commits
mailing list