Showing posts with label VoIP. Show all posts
Showing posts with label VoIP. Show all posts

Friday, November 28, 2008

OSS: A galore of choice or confusion

This thread gave birth to this post.

If you are a simple windows user and if you want to voice chat with a friend of yours, what will you do? Most likely you will download gtalk or YM messenger programs and chat with your friend.

But, what if you are using Linux? Will you use pidgin, kopete, ekiga, gizmo, kphone with your own asterisk/sipx setup, empathy, meebo, imo or the browser avatars of the YM or gtalk? While lot of this won't support voice or video, it is very unlikely that, as a novice user, you know about them.

So, you go and ask in a fsug forum. What do you find? 10 different users of the forum suggest 20 different solutions to you. It is not bad per say. After all, OSS is about choice, isn't it? However, our poor novice user tries these solutions one after the other. He may install a few which may not support some or other feature that he needs or after a successful installation of application (remember he is a novice user, he might have struggled for hours and hours), he will find that OS does support his hardware :(.

Result? Pop in a windows CD and say install and forget about OSS, free and geekdom. After all, windows is free for him, right? ;)

Now I had posted about this years back when there was a flood office suits in Linux which were using incompatible formats to save same kind of files. I don't know whether my arguments are still valid. However, let me start this argument with myself. I am not going into the details. Just adding some points as a starting point.

The arguments in favour of choice:
1. Well, how about same rice and sambar every day, everywhere? (A world with out choice will simply be... boring)

2. Every user has a different need. Different software are needed to satisfy this varying need.

3. It is impossible to combine all the features into one software. Even if we do that, it will lead to monopoly.

4. When a new user is asking for help, you should not try to impose your choice, but allow him to make his choice

5. Even on windows, today there is lot of choice

The arguments against choice
1. Ok, you want seven course dinner with varying dishes every day? Try telling this to your mom
(There are some cases at least, where choice is simply not possible. For instance, try choosing not to breathe or choose ears for breathing and keep yourself alive :) )

2. The classic example. MS Office. For years this has remained as the only office suite of choice. Even after the arrival of SO/OO, MS office is still there at the helm. Its positioned is not even threatened as much as IE is threatened by FF. So, it is possible, at least to a large extend, to satisfy the needs of a large user base with a single software. (Flare me... with the OOXML story..)

3. Monopoly? Tomorrow if Linux becomes the best OS and every one start using it, will you call that monopoly? Remember, it may not knowingly become anti-competitive deliberately. But, when you 'have' the 'best', will there be any desire for better than best?

4. Advice or informed advice?

5. Yes, but you guys are against windows, aren't you? Is it pro-choice or just against monopoly? There is a very subtle difference here!

There is lot more to write. But I have to do some coding now. I can only say BFN, the IM way :)

Monday, September 1, 2008

The channel woes

Today I was trying to register an asterisk channel. However my module registration failed with the error that module does not provide any description. I had half a mind to edit the line from Loader.c and load my module. However, I also noticed that I was compiling the module for one version (SVN trunk) and using it on some other version (1.4.15).

Then I downloaded asterisk from svn and compiled and installed it on some other machine. Then I just put in my simple module code, compiled, copied to /usr/lib/asterisk/modules/ and on the command line told "module load chan_thin" The stuff that was not happening for last two days just happened!

The sad part of my story is this. Till now the asterisk was giving me this message: "Module 'chan_thin.so' does not provide a description". I had tried various things including injecting the code of AST_MODULE_INFO macro into my module and adding checks on the functions used by that macro. I kept getting that vague error only because of some version change. (OK, it is still my mistake. Lot of things could have happened in a version change)

Anyway, now I have a module that goes in and does nothing. I have also checked oss channel driver in asterisk. I feel that is the most simple channel driver which I can use as a datum. More on it later. Before I end, let me put down a partial function call tree.

1. AST_MODULE_INFO -> Defines the module info and the register function. This registers ast_module_info
2. load_module -> This is made available to asterisk using ast_module_info structure. It is called when we load the module. For channel registration, ast_channel_register is called during load module. It passes a structure ast_channel_tech
3. ast_channel_tech -> This has all the callback functions. For OSS channel, the structure is as follows.

static struct ast_channel_tech oss_tech = {
.type = "Console",
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR, /* overwritten later */
.requester = oss_request,
.send_digit_begin = oss_digit_begin,
.send_digit_end = oss_digit_end,
.send_text = oss_text,
.hangup = oss_hangup,
.answer = oss_answer,
.read = oss_read,
.call = oss_call,
.write = oss_write,
.write_video = console_write_video,
.indicate = oss_indicate,
.fixup = oss_fixup,
};

4. oss_request -> This is the function that is called by asterisk when a call comes to your channel. The number is passed to you as a parameter to the function.

Got to do few more things. Rest later.

Sunday, August 31, 2008

Making of a channel

I need to answer 5 technical questions before I start making the channel

1. What does asterisk need from the channel? (What are the bare minimum features/functionalities of a channel?)
2. What all can asterisk take from the channel? (What is the largest possible set of features/functionalities that a channel can support out of the box?)
3. What are the features of the channel needed by the customer?
4. Is there any feature that a normal asterisk channel cannot support or it is very difficult to support?
5. How to add support to a new feature in channel?

I am searching the answer for the first question now.

Asterisk Channel

We have decided to make a new channel in Asterisk and almost completely move away from the zaptel channel. We had a discussion where we discussed how to proceed with the creation of the channel. In the discussion I was told that there is only a standard load_module function that is provided by Asterisk to define the channel. However, I was sure from my previous encounters with the channel that there needs to be something more than that and I even vaguely remembered that it is a structure.
Today I went back and had a look at the channel code and I found that channels infact use the structure ast_channel. I have not seen the code in detail. Will come back and post more once I see the channels in detail.

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.