Implementing a Channel

网友投稿 577 2022-10-03

Implementing a Channel

Implementing a Channel

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

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

* What do I need to create a channel?

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

* What's the general architecture?

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

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

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:一个账号只能开发一个小程序吗(一个人可以开发小程序吗)
下一篇:做微信小程序需要什么资质(微信小程序企业资质)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~