AGI wants to know which codec

Hey,

My AGI script downloads sound files and converts it to wav, but in order to offload work from asterisk, I want my script to be more intelligent and convert it to the correct format. So if the user is using the codec gsm, I want to convert my sound file to gsm etc…

Is there a channel variable I can use to find out the codec? I see that in ‘General’ when I show channel, there is NativeFormats, WriteFormat, and ReadFormat which seems to have my format. But this does not seem to be available to my agi script.

Any ideas of how to fetch the current codec?

Thanks,

David