| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Introduction} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | chan\_local is a pseudo-channel. Use of this channel simply loops calls back | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | into the dialplan in a different context. Useful for recursive routing. | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Syntax} | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  |  Local/extension@context[/{n|j}] | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | Adding "/n" at the end of the string will make the Local channel not do a | 
					
						
							|  |  |  | native transfer (the "n" stands for "n"o release) upon the remote end answering | 
					
						
							|  |  |  | the line. This is an esoteric, but important feature if you expect the Local | 
					
						
							|  |  |  | channel to handle calls exactly like a normal channel. If you do not have the | 
					
						
							|  |  |  | "no release" feature set, then as soon as the destination (inside of the Local | 
					
						
							| 
									
										
										
										
											2007-11-19 15:27:08 +00:00
										 |  |  | channel) answers the line and one audio frame passes, the variables and dial plan | 
					
						
							|  |  |  | will revert back to that of the original call, and the Local channel will become a | 
					
						
							|  |  |  | zombie and be removed from the active channels list. This is desirable in some | 
					
						
							|  |  |  | circumstances, but can result in unexpected dialplan behavior if you are doing | 
					
						
							|  |  |  | fancy things with variables in your call handling. | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | There is another option that can be used with local channels, which is the "j" | 
					
						
							|  |  |  | option.  The "j" option must be used with the "n" option to make sure that the | 
					
						
							|  |  |  | local channel does not get optimized out of the call.  This option will enable | 
					
						
							|  |  |  | a jitterbuffer on the local channel.  The jitterbuffer will be used to de-jitter | 
					
						
							|  |  |  | audio that it receives from the channel that called the local channel.  This is | 
					
						
							|  |  |  | especially in the case of putting chan\_local in between an incoming SIP call | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | and Asterisk applications, so that the incoming audio will be de-jittered. | 
					
						
							| 
									
										
										
										
											2007-10-09 15:10:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 17:53:58 +00:00
										 |  |  | Using the "m" option will cause chan\_local to forward music on hold start and stop | 
					
						
							|  |  |  | requests. Normally chan\_local acts on them and it is started or stopped on the | 
					
						
							| 
									
										
										
										
											2009-10-29 18:15:41 +00:00
										 |  |  | Local channel itself. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Purpose} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The Local channel construct can be used to establish dialing into any part of | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | the dialplan. | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | Imagine you have a TE410P in your box. You want to do something for which you | 
					
						
							|  |  |  | must use a Dial statement (for instance when dropping files in | 
					
						
							|  |  |  | \path{/var/spool/outgoing}) but you do want to be able to use your dialplans | 
					
						
							|  |  |  | least-cost-routes or other intelligent stuff. What you could do before we had | 
					
						
							|  |  |  | chan\_local was create a cross-link between two ports of the TE410P and then | 
					
						
							|  |  |  | Dial out one port and in the other. This way you could control where the call | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | was going. | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | Of course, this was a nasty hack, and to make it more sensible, chan\_local was | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | built. | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The "Local" channel driver allows you to convert an arbitrary extension into a | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | channel. It is used in a variety of places, including agents, etc. | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | This also allows us to hop to contexts like a GoSub routine; See examples below. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Examples} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | [inbound] ; here falls all incoming calls | 
					
						
							|  |  |  | exten => s,1,Answer | 
					
						
							| 
									
										
										
										
											2004-01-23 16:00:24 +00:00
										 |  |  | exten => s,2,Dial(local/200@internal,30,r) | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | exten => s,3,Playback(sorrynoanswer) | 
					
						
							|  |  |  | exten => s,4,Hangup | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [internal] ; here where our phones falls for default | 
					
						
							|  |  |  | exten => 200,1,Dial(sip/blah) | 
					
						
							|  |  |  | exten => 200,102,VoiceMail(${EXTEN}@default)
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | exten => 201,1,Dial(DAHDI/1) | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | exten => 201,102,VoiceMail(${EXTEN}@default)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | exten => _0.,1,Dial(DAHDI/g1/${EXTEN:1}) ; outgoing calls with 0+number
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Caveats} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | If you use chan\_local from a call-file and you want to pass channel variables | 
					
						
							|  |  |  | into your context, make sure you append the '/n', because otherwise | 
					
						
							|  |  |  | chan\_local will 'optimize' itself out of the call-path, and the variables will | 
					
						
							| 
									
										
										
										
											2007-10-12 15:50:29 +00:00
										 |  |  | get lost. i.e. | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2004-01-22 21:52:01 +00:00
										 |  |  |  Local/00531234567@pbx becomes Local/00531234567@pbx/n | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} |