Local channel optimization


this Asterisk wiki entry clearly states that Local channel will be optimized away as soon as audio starts flowing. However, when I run this example on Asterisk 18.3.0, optimization does not happen. I assume behavior has changed, without being documented. Is there any way I can make Local channel go away? In real world scenario, I will be putting the channel in dialplan instead of connecting it to Playback application directly.

It only optimises when there is a bridge on the ;2 side of the local channel. If it optimised in your case, the Playback would get aborted.

Well, in the example, the optimization happens after the first file is played. It clearly behaved in this manner at some point and, for my money, it makes sense. The more I think about it, the more it seems that channel optimization is of very limited usefulness if we can’t control when it happens. Anyway, I gather that the answer to my question if “no”.

The expected use is that you use the local channel to do a complex call set up, but once the the Dial has the call up, you no longer need the overhead, and the inability to do direct media.

Well, that is exactly the case here. I dialed inside the Local channel, and once the other side answers, I would expect the Local channel to go away, even before I do anything else. As the call is initiated from call file, there is no “other side”. It is completely safe to remove the Local channel, and then redirect real channel to wherever the call file specifies.

This got me thinking. Consider the following two call files:

Channel: LOCAL/${source}@originate_context
Context: call_context
Extension: ${destination}
Channel: LOCAL/${source}@originate_context
Application: Dial
Data: LOCAL/${destination}@call_context

Semantically, there is no difference in what these two call files do. But in the second case, the Local channel will be optimized away, assuming I answer in call_context. From my standpoint as an Asterisk user, this doesn’t make sense.

There is always another side in a bridged call.

You didn’t say that the local channel was on the A side of originate. It is what is run on the ;2 side of the local channel that should affect whether it optimises out, but you provided no details of that.

I think we need to see the full test dialplan to understand you case.

The full dialplan needed to understand the case is in the wiki entry that I linked. But anyway, there is a solution. Asterisk won’t optimize Local channel away, but in call_context I can identify the real channel, manually ChannelRedirect it wherever I want it to go, and hang up the Local channel. This is actually better, because I don’t depend on the magic Asterisk may or may not do behind the scenes. David, accept my sincere thanks for your answers. They pointed my thinking in the right direction.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.