aboutsummaryrefslogtreecommitdiffstats
path: root/rtp.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-15 00:36:05 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-15 00:36:05 +0000
commitdca83005a59655db2a4a4753779c9c43c216409e (patch)
tree9e45b7d281966c338192e4589b907fbcdfb18774 /rtp.c
parente055b3f202c1b036208a21bdaab0934e1ccfaac0 (diff)
- use '=' to copy struct sockaddr_in
- localize a variable - replace three replicas of the same code with a much simpler construct removing replicated var = var->next; - use '?' instead of 'if' for an assignment git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20224 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rw-r--r--rtp.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/rtp.c b/rtp.c
index 18c146696..a2646aa2f 100644
--- a/rtp.c
+++ b/rtp.c
@@ -432,7 +432,6 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
char iabuf[INET_ADDRSTRLEN];
unsigned int timestamp;
unsigned int *rtpheader;
- static struct ast_frame *f;
struct rtpPayloadType rtpPT;
len = sizeof(sin);
@@ -464,7 +463,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
/* Send to whoever sent to us */
if ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
(rtp->them.sin_port != sin.sin_port)) {
- memcpy(&rtp->them, &sin, sizeof(rtp->them));
+ rtp->them = sin;
rtp->rxseqno = 0;
ast_set_flag(rtp, FLAG_NAT_ACTIVE);
if (option_debug || rtpdebug)
@@ -509,6 +508,8 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
rtpPT = ast_rtp_lookup_pt(rtp, payloadtype);
if (!rtpPT.isAstFormat) {
+ struct ast_frame *f = NULL;
+
/* This is special in-band data that's not one of our codecs */
if (rtpPT.code == AST_RTP_DTMF) {
/* It's special -- rfc2833 process it */
@@ -530,41 +531,23 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (rtp->lasteventseqn <= seqno || rtp->resp == 0 || (rtp->lasteventseqn >= 65530 && seqno <= 6)) {
f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno);
rtp->lasteventseqn = seqno;
- } else
- f = NULL;
- if (f)
- return f;
- else
- return &ast_null_frame;
+ }
} else if (rtpPT.code == AST_RTP_CISCO_DTMF) {
/* It's really special -- process it the Cisco way */
if (rtp->lasteventseqn <= seqno || rtp->resp == 0 || (rtp->lasteventseqn >= 65530 && seqno <= 6)) {
f = process_cisco_dtmf(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
rtp->lasteventseqn = seqno;
- } else
- f = NULL;
- if (f)
- return f;
- else
- return &ast_null_frame;
+ }
} else if (rtpPT.code == AST_RTP_CN) {
/* Comfort Noise */
f = process_rfc3389(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
- if (f)
- return f;
- else
- return &ast_null_frame;
} else {
ast_log(LOG_NOTICE, "Unknown RTP codec %d received from '%s'\n", payloadtype, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
- return &ast_null_frame;
}
+ return f ? f : &ast_null_frame;
}
- rtp->f.subclass = rtpPT.code;
- if (rtp->f.subclass < AST_FORMAT_MAX_AUDIO)
- rtp->f.frametype = AST_FRAME_VOICE;
- else
- rtp->f.frametype = AST_FRAME_VIDEO;
- rtp->lastrxformat = rtp->f.subclass;
+ rtp->lastrxformat = rtp->f.subclass = rtpPT.code;
+ rtp->f.frametype = (rtp->f.subclass < AST_FORMAT_MAX_AUDIO) ? AST_FRAME_VOICE : AST_FRAME_VIDEO;
if (!rtp->lastrxts)
rtp->lastrxts = timestamp;