]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Local channels: Alternate solution to ringback problem. 55/955/2
authorMark Michelson <mmichelson@digium.com>
Thu, 23 Jul 2015 18:11:42 +0000 (13:11 -0500)
committerMark Michelson <mmichelson@digium.com>
Fri, 24 Jul 2015 14:31:23 +0000 (09:31 -0500)
Commit 54b25c80c8387aea9eb20f9f4f077486cbdf3e5d solved an issue where a
specific scenario involving local channels and a native local RTP bridge
could result in ringback still being heard on a calling channel even
after the call is bridged.

That commit caused many tests in the testsuite to fail with alarming
consequences, such as not sending DialBegin and DialEnd events, and
giving incorrect hangup causes during calls.

This commit reverts the previous commit and implements and alternate
solution. This new solution involves only passing AST_CONTROL_RINGING
frames across local channels if the local channel is in AST_STATE_RING.
Otherwise, the frame does not traverse the local channels. By doing
this, we can ensure that a playtones generator does not get started on
the calling channel but rather is started on the local channel on which
the ringing frame was initially indicated.

ASTERISK-25250 #close
Reported by Etienne Lessard

Change-Id: I3bc87a18a38eb2b68064f732d098edceb5c19f39

channels/chan_local.c

index 794bbae8b7185c04747fcc7d84062ce22daec9f8..562c181702b366bf97c1a705d7698d84b8c2a8ed 100644 (file)
@@ -751,10 +751,22 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da
                        res = local_queue_frame(p, isoutbound, &f, ast, 1);
                }
                ao2_unlock(p);
+       } else if (condition == AST_CONTROL_RINGING && ast_channel_state(ast) != AST_STATE_RING) {
+               /* Don't queue ringing frames if the channel is not in a "ring" state. Otherwise,
+                * the real channel on the other end will likely start a playtones generator. It is
+                * possible that this playtones generator will never be stopped under certain
+                * circumstances.
+                */
+               res = -1;
        } else {
                /* Queue up a frame representing the indication as a control frame */
                ao2_lock(p);
-               if (ast_test_flag(p, LOCAL_NO_OPTIMIZATION)) {
+               /*
+                * Block -1 stop tones events if we are to be optimized out.  We
+                * don't need a flurry of these events on an unreal channel chain
+                * when initially connected to slow the optimization process.
+                */
+               if (0 <= condition || ast_test_flag(p, LOCAL_NO_OPTIMIZATION)) {
                        isoutbound = IS_OUTBOUND(ast, p);
                        f.subclass.integer = condition;
                        f.data.ptr = (void *) data;