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}
This commit is contained in:
Karl Wiberg
2015-05-18 12:18:54 +02:00
parent 9d8b71e4c0
commit bd1bc47395
4 changed files with 37 additions and 66 deletions

View File

@ -11,7 +11,8 @@
#include "webrtc/modules/audio_coding/main/acm2/codec_manager.h"
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
@ -152,9 +153,8 @@ bool CodecSupported(const CodecInst& codec) {
const CodecInst kEmptyCodecInst = {-1, "noCodecRegistered", 0, 0, 0, 0};
} // namespace
CodecManager::CodecManager(AudioCodingModuleImpl* acm)
: acm_(acm),
cng_nb_pltype_(255),
CodecManager::CodecManager()
: cng_nb_pltype_(255),
cng_wb_pltype_(255),
cng_swb_pltype_(255),
cng_fb_pltype_(255),
@ -335,37 +335,6 @@ int CodecManager::SendCodec(CodecInst* current_codec) const {
return 0;
}
// Register possible receive codecs, can be called multiple times,
// for codecs, CNG (NB, WB and SWB), DTMF, RED.
int CodecManager::RegisterReceiveCodec(const CodecInst& codec) {
if (codec.channels > 2 || codec.channels < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
"Unsupported number of channels, %d.", codec.channels);
return -1;
}
int codec_id = ACMCodecDB::ReceiverCodecNumber(codec);
if (codec_id < 0 || codec_id >= ACMCodecDB::kNumCodecs) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
"Wrong codec params to be registered as receive codec");
return -1;
}
// Check if the payload-type is valid.
if (!ACMCodecDB::ValidPayloadType(codec.pltype)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
"Invalid payload-type %d for %s.", codec.pltype, codec.plname);
return -1;
}
// Get |decoder| associated with |codec|. |decoder| can be NULL if |codec|
// does not own its decoder.
// uint8_t payload_type = static_cast<uint8_t>(codec.pltype);
return acm_->RegisterDecoder(codec_id, codec.pltype, codec.channels,
GetAudioDecoder(codec));
}
bool CodecManager::SetCopyRed(bool enable) {
if (enable && codec_fec_enabled_) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, 0,