Chromium Code Reviews| Index: webrtc/modules/audio_coding/acm2/codec_manager.h | 
| diff --git a/webrtc/modules/audio_coding/acm2/codec_manager.h b/webrtc/modules/audio_coding/acm2/codec_manager.h | 
| index fbd3a18b188efa203949159bf0e0b8c9bde353b3..1c3be33d2d2742ca794dc09898c815d9d1e26a75 100644 | 
| --- a/webrtc/modules/audio_coding/acm2/codec_manager.h | 
| +++ b/webrtc/modules/audio_coding/acm2/codec_manager.h | 
| @@ -17,6 +17,7 @@ | 
| #include "webrtc/base/optional.h" | 
| #include "webrtc/base/thread_checker.h" | 
| #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" | 
| +#include "webrtc/modules/audio_coding/include/audio_coding_module.h" | 
| #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" | 
| #include "webrtc/common_types.h" | 
| @@ -55,6 +56,28 @@ class CodecManager final { | 
| bool SetCodecFEC(bool enable_codec_fec); | 
| + // Uses the provided Rent-A-Codec to create a new encoder stack, if we have a | 
| + // complete specification; if so, it is then passed to set_encoder. On error, | 
| + // returns false. | 
| + bool MakeEncoder(RentACodec* rac, AudioCodingModule* acm) { | 
| 
 
the sun
2016/04/06 11:58:25
In a big fan of DCHECKing pointers before I use th
 
kwiberg-webrtc
2016/04/06 12:15:29
I'm on the other side in this debate: since derefe
 
the sun
2016/04/06 13:05:59
The real reason for the DCHECKs is to document exp
 
 | 
| + if (!codec_stack_params_.speech_encoder && send_codec_inst_) { | 
| + // We have no speech encoder, but we have a specification for making one. | 
| + auto enc = rac->RentEncoder(*send_codec_inst_); | 
| + if (!enc) | 
| + return false; | 
| + codec_stack_params_.speech_encoder = std::move(enc); | 
| + } | 
| + auto stack = rac->RentEncoderStack(&codec_stack_params_); | 
| + if (stack) { | 
| + // Give new encoder stack to the ACM. | 
| + acm->SetEncoder(std::move(stack)); | 
| + } else { | 
| + // The specification was good but incomplete, so we have no encoder stack | 
| + // to give to the ACM. | 
| + } | 
| + return true; | 
| + } | 
| + | 
| private: | 
| rtc::ThreadChecker thread_checker_; | 
| rtc::Optional<CodecInst> send_codec_inst_; |