On 03/06/2025 21.31, Jeff Brower wrote:
> Per Richard's advice (below) I'm continuing this discussion here. We
> need to add AMR and EVS, and possibly other, codecs to rtpengine
We already support AMR and EVS, but it sounds like you want to supply
your own implementation?
...
>
> But that doesn't describe a lib (.so) API, and the 3GPP reference
> implementation reads in mime or G.192 files for decode. Are there
> specific C/C++ files that supply, via an API, bitstream frames for
> decode (and raw audio frames for encode) to the 3GPP reference
> implementation ? Are there similar source files for AMR ?
These instructions are specific to the EVS implementation and are needed
because it's the only one available (publicly) and it doesn't provide a
proper API or library that can be linked or used as-is. It's not typical
to how other codecs are implemented.
There isn't a singular API that is used for codec support. Instead
rtpengine supports a few different ones. Most codecs are supported
through the ffmpeg (libavcodec) API. The remaining ones are
codec-specific: There is separate support for Opus (libopus), EVS
(through the patched 3GPP codec), and G.729 (libbcg729). A few other
codecs are still implemented through ffmpeg but require some special
supporting code (AMR, iLBC).
The internal API is defined in `lib/codeclib.[ch]`. The primary
definition is via a `codec_type_t` object, which defines methods to open
and close an encoder or decoder, and encode and decode frames and
packets. See
https://github.com/sipwise/rtpengine/blob/master/lib/codeclib.c#L237
These are then referenced in the individual codec definitions
`codec_def_t`:
https://github.com/sipwise/rtpengine/blob/master/lib/codeclib.c#L338
Finally to maintain codec contexts, there are `encoder_t` and
`decoder_t` objects, which contain a union, with each member generally
corresponding to one codec type:
https://github.com/sipwise/rtpengine/blob/master/lib/codeclib.h#L286
The ffmpeg/libavcodec implementation is quite complicated so I would
suggest to ignore it and instead look at one of the simpler ones as an
example (e.g. bcg729).
Cheers