diff options
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; |