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

Alexander Traud pabstraud at compuserve.com
Fri Nov 20 09:53:18 CST 2015


>> 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).





More information about the asterisk-dev mailing list