Wednesday, May 28, 2008

Echo cancellation in Asterisk

"This software is not part of a normal Asterisk download because Digium has to pay to license it separately. Nevertheless, it has grandfathered it into all of its cards, so it is available for free to anyone who has a Digium analog card that is still under warranty. If you are running a non-Digium analog card, you can purchase a keycode for this software echo canceller from Digium’s web site."


Just tells me that I don't have to waste time on echo cancellation.

Monday, May 26, 2008

Exported functions of zaptel

Asterisk

zt_transcode_fops
A pointer to file operations structure. This is actually populated by zttranscode module. This is a pointer to __zt_transcode_fops defined by the zttranscode module. There is support for: open, release, ioctl, poll and mmap. This structure helps in transcoding.


zt_init_tone_state
Used to initialize the tone state for DTMF tone generation. These initialized values are used in tone generation.


zt_dtmf_tone
For the current channel, returns the DTMF tone structure for the specified digit.


zt_register
Registers a span with zaptel driver. This, I feel, is a method of registering a device with zaptel. The structure zt_span has all the components that is required for accessing/controlling the device. zt_span structure need to be studied in detail.


zt_unregister
Unregister spans registered using zt_register.


__zt_mulaw
ulaw conversion table.


__zt_alaw
alaw conversion table.


__zt_lineartoulaw
Function to convert linear samples to ulaw samples.


__zt_lineartoalaw
Function to convert linear samples to alaw samples.


__zt_lin2mu
Table for converting linear samples to ulaw samples


__zt_lin2a
Table for converting linear samples to alaw samples.


zt_lboname
Retrieve the LBO name strings from an array. LBO: Line build-out. Expressed in DBs. Decides the electrical length


zt_transmit
Transmit a chunk from the channel. There is more to it. Does some processing of slave channels etc. Need to see in detail.


zt_receive
Receives a chunk.Similar to zt_transmit. But it also handles in-band tones.


zt_rbsbits
Process robbed bit signaling. This is based on the channel signaling type.


zt_qevent_nolock
Queue an event for a channel. Do not lock the channel before doing it.


zt_qevent_lock
Queue an event for a channel. Lock the channel before queuing it.


zt_hooksig
Send hook status. (Off hook, on hook, ring etc)


zt_alarm_notify
Send an alarm to all channels in a span.


zt_set_dynamic_ioctl
Dynamically change the ioctl functions by passing a pointer to a new ioctl function.


zt_ec_chunk
Does echo cancellation on a chunk.


zt_ec_span
Does echo cancellation on an entire span.


zt_hdlc_abort
Send hdlc abort events to the channel.


zt_hdlc_finish
Read any remaining data from the channel.


zt_hdlc_getbuf
Copy data from the passed buffer to the output buffer.


zt_hdlc_putbuf
Copy data from the channel buffer to the passed buffer.


zt_alarm_channel
Send the alarm events to the channel.


zt_register_chardev
Register a character driver. Used by transcode module.


zt_unregister_chardev
Unregister the character device. Used by transcode module.


zt_dynamic_register
Takes a pointer to the driver structure and puts it on top of a linked list. The head of the linked list is a global variable called drivers.


zt_dynamic_unregister
Removes the driver from drivers linked list.


zt_dynamic_receive
Receive data for a channel. (Note: This and 3 functions above are for TDM over X. Currently X is ethernet)


zt_transcoder_register
List the transcoder in the global linked list 'trans'.


zt_transcoder_unregister
Remove the transcoder from the linked list pointed by trans


zt_transcoder_alert
Send an alert to the transcoder by setting an alert bit on transcoder status variable.


zt_transcoder_alloc
Allocate memory for a specified number of channels and initialize associated variables.


zt_transcoder_free
Free the memory allocated for a given transcoder.

Whats next?
a. Study the user space interaction of asterisk with zaptel (Chan_zap?)
b. Study the data flow in kernel
c. Study the working of a particular driver

I think, I will start with a & later move to b & c. In fact, it will be difficult to separate b & c.

Sunday, May 25, 2008

Installing F9

I had installed Fedora using qemu on a file a while back. I wanted it on my thumb drive also. The immediate solution that came to my mind was
qemu -cdrom f9.iso -hda /dev/sdb -m 256 -boot d

This worked fine till it started installing selinux targeted policy. Then it hung (crashed?). I tried to get rid of it by de-selecting some packages. But, I could not find selinux related packages in the customization list. So, I decided to pass enforcing=0 to kernel. Installing the package should not have caused a difference if the policy was not enforcing. I have no idea why, but, even that did not work.

Currently I am trying to install it using yum. Will post the details once I am done with it.

<update>
yum -c yum.conf --disablerepo=livna --disablerepo=fedora --disablerepo=updates --disablerepo=openswan --enablerepo=Fedora9 --installroot=/mnt install coreutils
yum -c yum.conf --disablerepo=livna --disablerepo=fedora --disablerepo=updates --disablerepo=openswan --enablerepo=Fedora9 --installroot=/mnt install vim
yum -c yum.conf --disablerepo=livna --disablerepo=fedora --disablerepo=updates --disablerepo=openswan --enablerepo=Fedora9 --installroot=/mnt install rpm
yum -c yum.conf --disablerepo=livna --disablerepo=fedora --disablerepo=updates --disablerepo=openswan --enablerepo=Fedora9 --installroot=/mnt install kernel
yum --disablerepo=updates --enablerepo=fedora --installroot=/mnt install grub

You will see that the last line is a bit different. This is because, previous line had installed yum and the new repos defined by the newly installed yum was used.

Fedora9 is my local Fedora9 repo created from rpms found in install DVD.

I could have done all these in one step.
yum -c yum.conf --disablerepo=livna --disablerepo=fedora
--disablerepo=updates --disablerepo=openswan --enablerepo=Fedora9
--installroot=/mnt install coreutils vim rpm kernel grub



Friday, May 23, 2008

Files

Below are the files that I want to concentrate on at the beginning

zaptel-base.c
zaptel.h
zconfig.h
ztd-eth.c
ztd-loc.c
ztdummy.c
ztdummy.h
ztdynamic.c
zttranscode.c

There is a large set of symbols that zaptel-base.c exports. First let me list all symbols that are being exported. (This symbol set, I guess, should define the API available for zaptel compatible drivers)

From zaptel-base.c

zt_transcode_fops
zt_init_tone_state
zt_dtmf_tone
zt_register
zt_unregister
__zt_mulaw
__zt_alaw
__zt_lineartoulaw
__zt_lineartoalaw
__zt_lin2mu
__zt_lin2a
zt_lboname
zt_transmit
zt_receive
zt_rbsbits
zt_qevent_nolock
zt_qevent_lock
zt_hooksig
zt_alarm_notify
zt_set_dynamic_ioctl
zt_ec_chunk
zt_ec_span
zt_hdlc_abort
zt_hdlc_finish
zt_hdlc_getbuf
zt_hdlc_putbuf
zt_alarm_channel
zt_register_chardev
zt_unregister_chardev


From ztdynamic.c

t_dynamic_register
zt_dynamic_unregister
zt_dynamic_receive


From zttranscode.c

zt_transcoder_register
zt_transcoder_unregister
zt_transcoder_alert
zt_transcoder_alloc
zt_transcoder_free


In coming days/hours I plan to make each of this symbol a link and write about the functionality of each item.

Asterisk/Zaptel/DAHDI

This is an attempt to study the zaptel interface used by Asterisk for enabling a few custom cards to work with Asterisk. I had started it few days back and plan to continue it for a while. When ever I find something interesting, I will post it here.