Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:24 2009

## Asterisk developer's documentation

# 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, ZAP, 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
  1. Call arrives on a channel driver interface
  2. Channel driver creates a PBX channel and starts a pbx thread on the channel
  3. The dial plan is executed
  4. At this point at least two things can happen:
     1. The call is answered by Asterisk and Asterisk plays a media stream or reads media
     2. 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:
  1. Dial creates an outbound PBX channel and asks one of the channel drivers to create a call
  2. 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
  3. 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.
  4. 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
  - Module: Asterisk Channel Drivers - Implemented channel drivers
  - AST Multimedia and signalling frames Asterisk Multimedia Frames