Restructure decoder registration in ACM
Before this change, a decoder was registered into ACMReceiver through
the CodecOwner; the CodecOwner had to have a pointer back to the
AudioCodingModuleImpl object to make this call. With this change, the
AudioCodingModuleImpl object asks the CodecOwner for a decoder pointer
instead, making the chain of calls more straightforward.
COAUTHOR=henrik.lundin@webrtc.org
BUG=4474
R=jmarusic@webrtc.org, minyue@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/52439004
Cr-Commit-Position: refs/heads/master@{#9204}
diff --git a/webrtc/modules/audio_coding/main/acm2/codec_manager.h b/webrtc/modules/audio_coding/main/acm2/codec_manager.h
index 610810c..2c54512 100644
--- a/webrtc/modules/audio_coding/main/acm2/codec_manager.h
+++ b/webrtc/modules/audio_coding/main/acm2/codec_manager.h
@@ -14,9 +14,6 @@
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_checker.h"
-#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
-#include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h"
-#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/codec_owner.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/common_types.h"
@@ -24,22 +21,20 @@
namespace webrtc {
class AudioDecoder;
+class AudioEncoder;
+class AudioEncoderMutable;
namespace acm2 {
-class AudioCodingModuleImpl;
-
class CodecManager final {
public:
- explicit CodecManager(AudioCodingModuleImpl* acm);
+ CodecManager();
~CodecManager();
int RegisterSendCodec(const CodecInst& send_codec);
int SendCodec(CodecInst* current_codec) const;
- int RegisterReceiveCodec(const CodecInst& receive_codec);
-
bool SetCopyRed(bool enable);
int SetVAD(bool enable, ACMVADMode mode);
@@ -48,6 +43,13 @@
int SetCodecFEC(bool enable_codec_fec);
+ // Returns a pointer to AudioDecoder of the given codec. For iSAC, encoding
+ // and decoding have to be performed on a shared codec instance. By calling
+ // this method, we get the codec instance that ACM owns.
+ // If |codec| does not share an instance between encoder and decoder, returns
+ // null.
+ AudioDecoder* GetAudioDecoder(const CodecInst& codec);
+
bool stereo_send() const { return stereo_send_; }
bool red_enabled() const { return red_enabled_; }
@@ -61,18 +63,10 @@
const AudioEncoder* CurrentEncoder() const { return codec_owner_.Encoder(); }
private:
- // Returns a pointer to AudioDecoder of the given codec. For iSAC, encoding
- // and decoding have to be performed on a shared codec instance. By calling
- // this method, we get the codec instance that ACM owns.
- // If |codec| does not share an instance between encoder and decoder, returns
- // null.
- AudioDecoder* GetAudioDecoder(const CodecInst& codec);
-
int CngPayloadType(int sample_rate_hz) const;
int RedPayloadType(int sample_rate_hz) const;
- AudioCodingModuleImpl* acm_;
rtc::ThreadChecker thread_checker_;
uint8_t cng_nb_pltype_;
uint8_t cng_wb_pltype_;