Switch to using new ACM methods for encoder management
BUG=webrtc:5028
Review URL: https://codereview.webrtc.org/1677013002
Cr-Commit-Position: refs/heads/master@{#12267}
diff --git a/webrtc/modules/utility/source/coder.cc b/webrtc/modules/utility/source/coder.cc
index 18b690d..1476e02 100644
--- a/webrtc/modules/utility/source/coder.cc
+++ b/webrtc/modules/utility/source/coder.cc
@@ -29,23 +29,19 @@
{
}
-int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst)
-{
- if(_acm->RegisterSendCodec((CodecInst&)codecInst) == -1)
- {
- return -1;
- }
- return 0;
+int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst) {
+ const bool success = codec_manager_.RegisterEncoder(codecInst) &&
+ codec_manager_.MakeEncoder(&rent_a_codec_, _acm.get());
+ return success ? 0 : -1;
}
-int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst)
-{
- if(_acm->RegisterReceiveCodec((CodecInst&)codecInst) == -1)
- {
- return -1;
- }
- memcpy(&_receiveCodec,&codecInst,sizeof(CodecInst));
- return 0;
+int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst) {
+ if (_acm->RegisterReceiveCodec(
+ codecInst, [&] { return rent_a_codec_.RentIsacDecoder(); }) == -1) {
+ return -1;
+ }
+ memcpy(&_receiveCodec, &codecInst, sizeof(CodecInst));
+ return 0;
}
int32_t AudioCoder::Decode(AudioFrame& decodedAudio,