Just wanted to let you all know that the AudioEncoder interface is changing - specifically AudioEncoder::Encode and AudioEncoder::MaxEncodedBytes.
This change hands the responsibility of ensuring the buffer is large enough to the encoder implementation, rather than the caller. Specifically, this means:
- Encode() and EncodeInternal() now take an rtc::Buffer*, rather than a size_t and a uint8_t*.
- Encoding calls are now expected to append data to the buffer, rather than overwrite it. New implementations of EncodeInternal() should append the encoded data to the buffer!
- MaxEncodedBytes() will disappear, since the caller no longer needs to handle the buffer size manually.
- The new version of EncodeInternal() is now protected rather than public, since EncodeInternal() should not be called directly by user code.
The internal codecs, as well as calls to Encode(), have been changed to match this. There are currently backwards compatible versions of Encode() and EncodeInternal() that will ensure old encoder implementations work with callers using the new interface and vice-versa.
We plan to remove this backwards compatibility by Apr 8th, 2016.
What should I do?
If you've written code that calls Encode() on an encoder, you should update the call to use the new signature. This means you should no longer have to manage the output buffer manually, as rtc::Buffer is growable.
Remember: Encode() now appends data to the buffer. Call Clear() on it first, if you don't want to continuously accumulate encoded audio. Also, make sure you don't call MaxEncodedBytes() anywhere.
If you've written an AudioEncoder implementation, you should change it to implement the new variant of EncodeInternal(). This means ensuring the buffer is large enough, expanding it if necessary, and appending the encoded data to it. Fortunately, there is handy functionality in rtc::Buffer to do just that.