Fri Mar 7 07:00:00 CET 2003

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@634 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matteo Brancaleoni
2003-03-07 06:00:13 +00:00
parent a8723ad68f
commit f2c4538f61
13 changed files with 419 additions and 25 deletions

11
rtp.c
View File

@@ -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;