Capturing incoming audio stream


I have a SIP to SIP channel setup through my Asterisk server. I need to access the audio stream that is coming from one SIP phone to the other and process it before sending it on an outgoing channel to the dialled SIP phone. Can anybody help me in understanding how to do this. I understand that this can be achieved by some functions from channel.C but do not have any details of the implementation.

Thanks in advance


You can look for frames. There are voice frames you need.
Function is:
static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)

Thanks. I will try it out.

Could you provide any example where this function has been used? Any code through which I could understand the usage of these frames by Asterisk would be greatly helpful. Thanks

Function is in channel.c
In one of my projects I had to manipulate DTMFs and found that the best place to attach my modifications is there.
You have similar functions for sip and IAX - in other files of course.
Also I had to modify alsa (other project) - sound frames are 20 ms long (160 samples), and I had hardware which required 256 samples. I mention this because your algorithm could require longer frames.

It is not very easy to inject code in channel.c - and is even harder to debug it.
But - I am working as freelancer, if you need more assistance - I can imagine couple of ways to offer more help, keeping confidence.

Thanks for the help. In case we decide to hire a professional, I will get in touch with you.