[asterisk-dev] understanding ast_codec_get_samples for AMR

Steve Kann stevek at stevek.com
Tue Nov 21 13:42:48 MST 2006


On Nov 21, 2006, at 1:06 PM, Steven Critchfield wrote:

> On Tue, 2006-11-21 at 17:10 +0000, Ian Hailey wrote:
>> I am assuming that the function is called once per speech frame (i.e.
>> per time perios e.g. 20ms for GSM, AMR etc.)
>
> You are assuming that we will always have only 20ms packets then.  
> There
> have been people here talking about wanting to have 30 or 40 ms  
> packets
> or whatever. So you can't always assume the you will be getting the  
> same
> thing. I am sure there are scenarios out there where the number may
> change as the call progresses. Maybe something along the lines of a
> transfer changing negotiated codecs or packet lengths.

The whole point of ast_codec_get_samples is that we're _not_ assuming  
the number of samples in a frame;
That's the return value of the function.  It returns the number of  
samples in a frame.

I haven't checked on the implementation lately, but it does actually  
peek inside speex frames and parse them to determine the number of  
samples.  For fixed-bitrate frames, It just divides the number of  
bytes to figure it out.  I'm not sure if it works properly for iLBC.

For AMR, I would have it do the same thing as speex does.  For speex,  
it was about 50-100 lines of code to parse the frames and determine  
the number of samples.

-SteveK





More information about the asterisk-dev mailing list