Logo




Subscribe:
RSS 2.0 | Atom 1.0
Categories:

Sign In


[Giagnocavo]Michael::Write()

# Sunday, January 16, 2005
My first open source contribution

I ran into an issue with Asterisk, mainly that you can't dynamically control which codec gets accepted. You have to make your choice “up front”, when you define a user/peer. This means, for example, if you want to say “for this call, use the GSM codec”, you can't. You've got to let Asterisk's code work things out, and even it works out on your side, the callee might decide to use a different codec anyways. This means that I end up declaring various peers: peerX-g729, peerX-ulaw, etc., and then have to swap them out when I call Dial.

Even worse, there's no easy way of completely avoiding transcoding when you want to. For instance, I have several phones connected to my server. Some use GSM, some use ULAW, some use G.729. They all use the same dialplan, and ulaw is usually negotiated for the termination. That means my little server gets nailed doing all this transcoding. This is even sillier when you realise that my termination provider has big hardware and will handle transcoding for me. So, without making a seriously complex dialplan, I'm stuck.

Well, IMO, that sucks.

So, I actually dove into the code, and patched it: http://bugs.digium.com/bug_view_page.php?bug_id=0003346 I've yet to see if this will get into the actual codebase. I sure hope so, since I *hate* forking. Indeed, that's one major criticism I have of the “you can just modify it to suit your needs“ claims of OSS. But, the ones in power seem quite rational, so there's some hope... maybe :).

Asterisk is a large project, but thanks to Visual C++ 2005, I could navigate it (New Project From Existing Code is very useful!). Unfortunately, I think there's a bug, as VS takes up 1.4GB of memory when editing this project. However, it's still quite responsive -- except for the Virtual Memory Warning from Windows, and the initial slowness, I'd never notice it was eating all that memory.

Code | Asterisk
Sunday, January 16, 2005 4:03:31 AM UTC  #    Comments [1]  |  Trackback

Sunday, January 16, 2005 4:58:19 PM UTC
I know nothing about the codecs you are dealing with but can you make Dial a recursive call and sample the the codecs on the other end and determine dynamically what they are using? Then keep on calling Dial while the codecs don't match and if you reach the end of all known codecs and you haven't found a match then pop up an error saying codec unknown or something?

Or maybe you could do it like buffering an image stream you sample the first X number of bytes and determine the image format before uploading the image to the server or device. If each codec returns a set pattern like images do, you can create a sort of keygen that generates a unique key for each codec and have a B-tree that uses the unique keys as it's key and each node's data is a function pointer to the function that deals with that codec. You can do this with images using std::map.

I don't know anything about codecs though so I don't know if you can buffer them and sample them like you can with images.
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview