aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-22 01:24:10 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-22 01:24:10 +0000
commit53df8ffbc3e41dbf749b3774486eaeac5ebd9a22 (patch)
tree0a3592f602805ca399977e81d73a631790e7ab8b
parent2c9f09970b0ce9c29608a1fb9b9d9a8ea14efcb6 (diff)
Restructure a little bit of code to reduce nesting. There is no functionality
change here. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@56055 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 77861078d..216eae78c 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -4074,37 +4074,38 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
(ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833))
return &ast_null_frame;
- if (p->owner) {
/* We already hold the channel lock */
- if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (!(f->subclass & p->jointcapability)) {
- if (option_debug) {
- ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
- ast_getformatname(f->subclass), p->owner->name);
- }
- return &ast_null_frame;
- }
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
- p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
- ast_set_read_format(p->owner, p->owner->readformat);
- ast_set_write_format(p->owner, p->owner->writeformat);
+ if (!p->owner || f->frametype != AST_FRAME_VOICE)
+ return f;
+
+ if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+ if (!(f->subclass & p->jointcapability)) {
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
+ ast_getformatname(f->subclass), p->owner->name);
}
- if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
- f = ast_dsp_process(p->owner, p->vad, f);
- if (f && f->frametype == AST_FRAME_DTMF) {
- if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
- *faxdetect = 1;
- } else if (option_debug) {
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
- }
- }
+ return &ast_null_frame;
+ }
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ p->owner->nativeformats = (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
+ ast_set_read_format(p->owner, p->owner->readformat);
+ ast_set_write_format(p->owner, p->owner->writeformat);
+ }
+
+ if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
+ f = ast_dsp_process(p->owner, p->vad, f);
+ if (f && f->frametype == AST_FRAME_DTMF) {
+ if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+ *faxdetect = 1;
+ } else if (option_debug) {
+ ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
}
}
}
+
return f;
}