[asterisk-dev] Purpose of Codecs with Multiple Sample Rates?

Joshua Colp jcolp at digium.com
Fri Nov 20 09:58:30 CST 2015


Alexander Traud wrote:
>>> ast_format_cache_get(.) does not work for Speex.
>
> ASTERISK-25535 shows this, for example with chan_sip:
> ast_format_cap_append_by_type(sip_tech.capabilities, AST_MEDIA_TYPE_AUDIO);
>     ast_format_cap_append_by_type
>        ast_format_cache_get(ast_codec->name)
> Here, the source code deals with ast_codec. Now, an ast_format must be
> created from the name of a codec. In case of Speex, the name of the codec is
> the same for all rates: speex. Therefore, the cache cannot be accessed that
> way for speex16 or speex24 because it would return speex[8] always.
>
> Therefore, I had to add "codec != ast_format_get_codec(format)" in that
> patch. If each Speex format has a unique codec->name, no (unnecessary) new
> formats will be created. In case of AMR, this behavior has two additional
> implications, but that should be sufficient as example.
>
> Slin could be worked-around via
> ast_format_cache_is_slinear(format), and
> ast_format_cache_get_slin_by_rate(ast_codec->sample_rate).

When I originally reviewed that code I forgot about that limitation. The 
way to fix it for all would be to extend the format cache API to allow 
you to provide a codec for getting a cached format, and then it would 
return the closest cached format based on that.

I'm not sure if I'm willing to make such a substantial change with 
changing codec names. That potentially has far reaching consequences.

-- 
Joshua Colp
Digium, Inc. | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org



More information about the asterisk-dev mailing list