Implementing a Channel

本文介绍了Asterisk PBX中的通道概念及其实现原理。每个电话呼叫通过特定的通道进行处理,Asterisk使用通道驱动来支持不同类型的硬件。文章还详细解释了创建新通道所需的步骤,包括编写通道驱动程序及其一般架构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A channel is a unit which brings in a call to the Asterisk PBX. A channel
could be connected to a real telephone (like the Internet Phone Jack) or
to a logical call (like an Internet phone call). Asterisk makes no
distinction between "FXO" and "FXS" style channels (that is, it doesn't
distinguish between telephone lines and telephones).

Every call is placed or received on a distinct channel. Asterisk uses a
channel driver (typically named chan_xxx.so) to support each type of
hardware.

* What do I need to create a channel?

In order to support a new piece of hardware you need to write a channel
driver. The easiest way to do so is to look at an existing channel driver
and model your own code after it.

* What's the general architecture?

Typically, a channel reads a configuration file on startup which tells it
something about the hardware it's going to be servicing. Then, it
launches a thread which monitors all the idle channels (See the chan_modem
or the chan_ixj for an example of this). When a "RING" or equivalent is
detected, the monitoring thread should allocate a channel structure and
assign all the callbacks to it (see ixj_new, for example), and then call
ast_pbx_start on that channel. ast_pbx_start will launch a new thread to
handle the channel as long as the call is up, so once pbx_start has
successfully been run, the monitor should no longer monitor that channel.
The PBX thread will use the channel, reading, writing, calling, etc., and
multiplexing that channel with others using select() on the channel's
file descriptor (if your channel doesn't have an associated file
descriptor, you'll need to emulate one somehow, perhaps along the lines of
what the translator API does with its channel.

When the PBX is finished with the line, it will hang up the line, at which
point it the hardware should again be monitored by the monitoring thread.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值