chan_iax2: Prevent some needless breaking of the native IAX2 bridge.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 24 Sep 2013 20:37:32 +0000 (20:37 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 24 Sep 2013 20:37:32 +0000 (20:37 +0000)
* Clean up some twisted code in the iax2_bridge() loop.

* Add AST_CONTROL_VIDUPDATE and AST_CONTROL_SRCCHANGE to a list of frames
to prevent the native bridge loop from breaking.

* Passing the AST_CONTROL_T38_PARAMETERS frame should also allow FAX over
a native IAX2 bridge.

(issue ABE-2912)

Review: https://reviewboard.asterisk.org/r/2870/
........

Merged revisions 399697 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 399708 from http://svn.asterisk.org/svn/asterisk/branches/11

For v12 and above this is really just documentation until IAX2 native
bridging is restored.
........

Merged revisions 399736 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399737 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index a9ea437..fb68131 100644 (file)
@@ -5516,34 +5516,44 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
                        break;
                }
                other = (who == c0) ? c1 : c0;  /* the 'other' channel */
-               if ((f->frametype == AST_FRAME_CONTROL)) {
-                       if (f->subclass.integer == AST_CONTROL_PVT_CAUSE_CODE) {
+               if (f->frametype == AST_FRAME_CONTROL) {
+                       switch (f->subclass.integer) {
+                       case AST_CONTROL_VIDUPDATE:
+                       case AST_CONTROL_SRCUPDATE:
+                       case AST_CONTROL_SRCCHANGE:
+                       case AST_CONTROL_T38_PARAMETERS:
+                               ast_write(other, f);
+                               break;
+                       case AST_CONTROL_PVT_CAUSE_CODE:
                                ast_channel_hangupcause_hash_set(other, f->data.ptr, f->datalen);
-                       } else if (f->subclass.integer != AST_CONTROL_SRCUPDATE) {
+                               break;
+                       default:
                                *fo = f;
                                *rc = who;
-                               res =  AST_BRIDGE_COMPLETE;
+                               res = AST_BRIDGE_COMPLETE;
                                break;
                        }
-               }
-               if ((f->frametype == AST_FRAME_VOICE) ||
-                       (f->frametype == AST_FRAME_TEXT) ||
-                       (f->frametype == AST_FRAME_VIDEO) ||
-                       (f->frametype == AST_FRAME_IMAGE) ||
-                       (f->frametype == AST_FRAME_DTMF) ||
-                       (f->frametype == AST_FRAME_CONTROL && f->subclass.integer != AST_CONTROL_PVT_CAUSE_CODE)) {
+                       if (res == AST_BRIDGE_COMPLETE) {
+                               break;
+                       }
+               } else if (f->frametype == AST_FRAME_VOICE
+                       || f->frametype == AST_FRAME_TEXT
+                       || f->frametype == AST_FRAME_VIDEO
+                       || f->frametype == AST_FRAME_IMAGE) {
+                       ast_write(other, f);
+               } else if (f->frametype == AST_FRAME_DTMF) {
                        /* monitored dtmf take out of the bridge.
                         * check if we monitor the specific source.
                         */
                        int monitored_source = (who == c0) ? AST_BRIDGE_DTMF_CHANNEL_0 : AST_BRIDGE_DTMF_CHANNEL_1;
-                       if (f->frametype == AST_FRAME_DTMF && (flags & monitored_source)) {
+
+                       if (flags & monitored_source) {
                                *rc = who;
                                *fo = f;
                                res = AST_BRIDGE_COMPLETE;
                                /* Remove from native mode */
                                break;
                        }
-                       /* everything else goes to the other side */
                        ast_write(other, f);
                }
                ast_frfree(f);