Due to the need of VoIP projects at work, I recently got in close contact with the asterisk engineering code. As for the great Position and Role of Asterisk in VoIP, I will not talk about it. Please refer to the previous article: astersik + radius simple strategy.
The introduction of Asterisk materials in China, let alone the source code analysis of Asterisk, so I will share some of the information I usually remember with you, hoping to help my colleagues. The first article translates the channel concept in Asterisk. the original English text can be found:Http://www.asterisk.org/doxygen/1.4/
What is an asterisk channel?
The asterisk channel is a call established through the asterisk. All these calls contain an incoming connection and an outbound connection. Each phone is built through a channel driver, such as sip, zap, and iax2. Each type of channel driver has its own private channel data structure. These private structures belong to a common asterisk channel data structure, which is defined in the channel. H and channel. c.
Call scenario)
The following figure shows the situation when an incoming call arrives at asterisk:
- The arrival of a call is perceived by interfaces driven by a certain channel, such as sip socket;
- The channel driver creates a PBX channel for it and opens a PBX thread for the channel;
- Implement the dialing scheme;
- At this time, at least one of the following occurs:
A. Asterisk responds to this call and plays media data or reads media data, such as IVR services.
B. the dialing scheme prompts asterisk to create an external call through the dial application, such as connecting to the local gateway when calling a landline or mobile phone. (For details, see app_dial.c)
Bridging Channels)
The following figure shows the asterisk outbound dialing scenario:
- Dial creates an outbound PBX channel and requires the corresponding channel driver to create a call
- When the phone is connected, asterisk bridges the media stream so that the caller of the first channel can communicate with the caller of the second channel.
- In some cases, the inbound and outbound channels use the same technical solution and compatible codec technology. In this case, local bridging is used. In this local bridging scheme, the channel driver directly transmits incoming voice data to external streams without sending voice frames through the PBX.
- For the SIP protocol, there will be an "external native bridge", asterisk redirection endpoint, so that the voice is directly transmitted between the caller and the called. Signals are stored to provide correct CDR records.
Masquerading Channels)
In some cases, one channel may be implanted into another channel. This scenario is common in call transfer. When a new channel is implanted and takes over the bridge, the old channel becomes frozen and suspended.