diff options
author | matteo <matteo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-03-07 06:00:13 +0000 |
---|---|---|
committer | matteo <matteo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-03-07 06:00:13 +0000 |
commit | 6cef720265d690adb0270c833a0b05a515bad810 (patch) | |
tree | 9cf97910c36b158e27853b640770c246ff9e8066 /rtp.c | |
parent | 005002c26620c61597ef18c19707c150b72ffccb (diff) |
Fri Mar 7 07:00:00 CET 2003
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@634 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-x | rtp.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -50,6 +50,7 @@ struct ast_rtp { int lasttxformat; int lastrxformat; int dtmfcount; + int nat; struct sockaddr_in us; struct sockaddr_in them; struct timeval rxcore; @@ -114,6 +115,11 @@ void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback) rtp->callback = callback; } +void ast_rtp_setnat(struct ast_rtp *rtp, int nat) +{ + rtp->nat = nat; +} + static struct ast_frame *send_dtmf(struct ast_rtp *rtp) { ast_log(LOG_DEBUG, "Sending dtmf: %d (%c)\n", rtp->resp, rtp->resp); @@ -262,6 +268,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) res = recvfrom(rtp->s, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET, 0, (struct sockaddr *)&sin, &len); + rtpheader = (unsigned int *)(rtp->rawdata + AST_FRIENDLY_OFFSET); if (res < 0) { ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno)); @@ -273,6 +280,10 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) ast_log(LOG_WARNING, "RTP Read too short\n"); return &null_frame; } + if (rtp->nat) { + /* Send to whoever sent to us */ + memcpy(&rtp->them, &sin, sizeof(rtp->them)); + } /* Get fields */ seqno = ntohl(rtpheader[0]); payloadtype = (seqno & 0x7f0000) >> 16; |