Asterisk - The Open Source Telephony Project GIT-master-f36a736
Asterisk Channels
What is a Channel?
A phone call through Asterisk consists of an incoming connection and an outbound connection. Each call comes in through a channel driver that supports one technology, like SIP, DAHDI, IAX2 etc.
Each channel driver, technology, has it's own private channel or dialog structure, that is technology-dependent. Each private structure is "owned" by a generic Asterisk channel structure, defined in channel.h and handled by channel.c .
Call scenario
This happens when an incoming call arrives to Asterisk
Call arrives on a channel driver interface
Channel driver creates a PBX channel and starts a pbx thread on the channel
The dial plan is executed
At this point at least two things can happen:
The call is answered by Asterisk and Asterisk plays a media stream or reads media
The dial plan forces Asterisk to create an outbound call somewhere with the dial (see app_dial.c) application
Bridging channels
If Asterisk dials out this happens:
Dial creates an outbound PBX channel and asks one of the channel drivers to create a call
When the call is answered, Asterisk bridges the media streams so the caller on the first channel can speak with the callee on the second, outbound channel
In some cases where we have the same technology on both channels and compatible codecs, a native bridge is used. In a native bridge, the channel driver handles forwarding of incoming audio to the outbound stream internally, without sending audio frames through the PBX.
In SIP, theres an "external native bridge" where Asterisk redirects the endpoint, so audio flows directly between the caller's phone and the callee's phone. Signalling stays in Asterisk in order to be able to provide a proper CDR record for the call.
Masquerading channels
In some cases, a channel can masquerade itself into another channel. This happens frequently in call transfers, where a new channel takes over a channel that is already involved in a call. The new channel sneaks in and takes over the bridge and the old channel, now a zombie, is hung up.
Reference
channel.c - generic functions
channel.h - declarations of functions, flags and structures