Starting to implement the new ACM API
The new implementation class is called AudioCodingImpl, and will in the end replace AudioCodingModuleImpl. This is work in progress. BUG=3520 R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/17359004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7103 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -94,4 +94,8 @@ bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioCoding* AudioCoding::Create(const Config& config) {
|
||||||
|
return new AudioCodingImpl(config);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/engine_configurations.h"
|
#include "webrtc/engine_configurations.h"
|
||||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||||
#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
|
#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
|
||||||
@ -2053,4 +2054,255 @@ void AudioCodingModuleImpl::GetDecodingCallStatistics(
|
|||||||
|
|
||||||
} // namespace acm2
|
} // namespace acm2
|
||||||
|
|
||||||
|
bool AudioCodingImpl::RegisterSendCodec(AudioEncoder* send_codec) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::RegisterSendCodec(int encoder_type,
|
||||||
|
uint8_t payload_type,
|
||||||
|
int frame_size_samples) {
|
||||||
|
std::string codec_name;
|
||||||
|
int sample_rate_hz;
|
||||||
|
int channels;
|
||||||
|
if (!MapCodecTypeToParameters(
|
||||||
|
encoder_type, &codec_name, &sample_rate_hz, &channels)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
webrtc::CodecInst codec;
|
||||||
|
AudioCodingModule::Codec(
|
||||||
|
codec_name.c_str(), &codec, sample_rate_hz, channels);
|
||||||
|
codec.pltype = payload_type;
|
||||||
|
if (frame_size_samples > 0) {
|
||||||
|
codec.pacsize = frame_size_samples;
|
||||||
|
}
|
||||||
|
return acm_old_->RegisterSendCodec(codec) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AudioEncoder* AudioCodingImpl::GetSenderInfo() const {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioCodingImpl::Add10MsAudio(const AudioFrame& audio_frame) {
|
||||||
|
if (acm_old_->Add10MsData(audio_frame) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return acm_old_->Process();
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReceiverInfo* AudioCodingImpl::GetReceiverInfo() const {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::RegisterReceiveCodec(AudioDecoder* receive_codec) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::RegisterReceiveCodec(int decoder_type,
|
||||||
|
uint8_t payload_type) {
|
||||||
|
std::string codec_name;
|
||||||
|
int sample_rate_hz;
|
||||||
|
int channels;
|
||||||
|
if (!MapCodecTypeToParameters(
|
||||||
|
decoder_type, &codec_name, &sample_rate_hz, &channels)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
webrtc::CodecInst codec;
|
||||||
|
AudioCodingModule::Codec(
|
||||||
|
codec_name.c_str(), &codec, sample_rate_hz, channels);
|
||||||
|
codec.pltype = payload_type;
|
||||||
|
return acm_old_->RegisterReceiveCodec(codec) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::InsertPacket(const uint8_t* incoming_payload,
|
||||||
|
int32_t payload_len_bytes,
|
||||||
|
const WebRtcRTPHeader& rtp_info) {
|
||||||
|
return acm_old_->IncomingPacket(
|
||||||
|
incoming_payload, payload_len_bytes, rtp_info) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::InsertPayload(const uint8_t* incoming_payload,
|
||||||
|
int32_t payload_len_byte,
|
||||||
|
uint8_t payload_type,
|
||||||
|
uint32_t timestamp) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::SetMinimumPlayoutDelay(int time_ms) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::SetMaximumPlayoutDelay(int time_ms) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioCodingImpl::LeastRequiredDelayMs() const {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::PlayoutTimestamp(uint32_t* timestamp) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::Get10MsAudio(AudioFrame* audio_frame) {
|
||||||
|
return acm_old_->PlayoutData10Ms(playout_frequency_hz_, audio_frame) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::NetworkStatistics(
|
||||||
|
ACMNetworkStatistics* network_statistics) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::EnableNack(size_t max_nack_list_size) {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioCodingImpl::DisableNack() {
|
||||||
|
FATAL() << "Not implemented yet.";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint16_t> AudioCodingImpl::GetNackList(
|
||||||
|
int round_trip_time_ms) const {
|
||||||
|
return acm_old_->GetNackList(round_trip_time_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioCodingImpl::GetDecodingCallStatistics(
|
||||||
|
AudioDecodingCallStats* call_stats) const {
|
||||||
|
acm_old_->GetDecodingCallStatistics(call_stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioCodingImpl::MapCodecTypeToParameters(int codec_type,
|
||||||
|
std::string* codec_name,
|
||||||
|
int* sample_rate_hz,
|
||||||
|
int* channels) {
|
||||||
|
switch (codec_type) {
|
||||||
|
#ifdef WEBRTC_CODEC_PCM16
|
||||||
|
case acm2::ACMCodecDB::kPCM16B:
|
||||||
|
*codec_name = "L16";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCM16Bwb:
|
||||||
|
*codec_name = "L16";
|
||||||
|
*sample_rate_hz = 16000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCM16Bswb32kHz:
|
||||||
|
*codec_name = "L16";
|
||||||
|
*sample_rate_hz = 32000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCM16B_2ch:
|
||||||
|
*codec_name = "L16";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCM16Bwb_2ch:
|
||||||
|
*codec_name = "L16";
|
||||||
|
*sample_rate_hz = 16000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCM16Bswb32kHz_2ch:
|
||||||
|
*codec_name = "L16";
|
||||||
|
*sample_rate_hz = 32000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
|
||||||
|
case acm2::ACMCodecDB::kISAC:
|
||||||
|
*codec_name = "ISAC";
|
||||||
|
*sample_rate_hz = 16000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef WEBRTC_CODEC_ISAC
|
||||||
|
case acm2::ACMCodecDB::kISACSWB:
|
||||||
|
*codec_name = "ISAC";
|
||||||
|
*sample_rate_hz = 32000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kISACFB:
|
||||||
|
*codec_name = "ISAC";
|
||||||
|
*sample_rate_hz = 48000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef WEBRTC_CODEC_ILBC
|
||||||
|
case acm2::ACMCodecDB::kILBC:
|
||||||
|
*codec_name = "ILBC";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case acm2::ACMCodecDB::kPCMA:
|
||||||
|
*codec_name = "PCMA";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCMA_2ch:
|
||||||
|
*codec_name = "PCMA";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCMU:
|
||||||
|
*codec_name = "PCMU";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kPCMU_2ch:
|
||||||
|
*codec_name = "PCMU";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
#ifdef WEBRTC_CODEC_G722
|
||||||
|
case acm2::ACMCodecDB::kG722:
|
||||||
|
*codec_name = "G722";
|
||||||
|
*sample_rate_hz = 16000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kG722_2ch:
|
||||||
|
*codec_name = "G722";
|
||||||
|
*sample_rate_hz = 16000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef WEBRTC_CODEC_OPUS
|
||||||
|
case acm2::ACMCodecDB::kOpus:
|
||||||
|
*codec_name = "opus";
|
||||||
|
*sample_rate_hz = 48000;
|
||||||
|
*channels = 2;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case acm2::ACMCodecDB::kCNNB:
|
||||||
|
*codec_name = "CN";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kCNWB:
|
||||||
|
*codec_name = "CN";
|
||||||
|
*sample_rate_hz = 16000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kCNSWB:
|
||||||
|
*codec_name = "CN";
|
||||||
|
*sample_rate_hz = 32000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
case acm2::ACMCodecDB::kRED:
|
||||||
|
*codec_name = "red";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
#ifdef WEBRTC_CODEC_AVT
|
||||||
|
case acm2::ACMCodecDB::kAVT:
|
||||||
|
*codec_name = "telephone-event";
|
||||||
|
*sample_rate_hz = 8000;
|
||||||
|
*channels = 1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
FATAL() << "Codec type " << codec_type << " not supported.";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -382,6 +382,88 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
|||||||
|
|
||||||
} // namespace acm2
|
} // namespace acm2
|
||||||
|
|
||||||
|
class AudioCodingImpl : public AudioCoding {
|
||||||
|
public:
|
||||||
|
AudioCodingImpl(const Config& config) {
|
||||||
|
AudioCodingModule::Config config_old;
|
||||||
|
config_old.id = 0;
|
||||||
|
config_old.neteq_config = config.neteq_config;
|
||||||
|
config_old.clock = config.clock;
|
||||||
|
acm_old_.reset(new acm2::AudioCodingModuleImpl(config_old));
|
||||||
|
acm_old_->RegisterTransportCallback(config.transport);
|
||||||
|
acm_old_->RegisterVADCallback(config.vad_callback);
|
||||||
|
acm_old_->SetDtmfPlayoutStatus(config.play_dtmf);
|
||||||
|
if (config.initial_playout_delay_ms > 0) {
|
||||||
|
acm_old_->SetInitialPlayoutDelay(config.initial_playout_delay_ms);
|
||||||
|
}
|
||||||
|
playout_frequency_hz_ = config.playout_frequency_hz;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~AudioCodingImpl() OVERRIDE {};
|
||||||
|
|
||||||
|
virtual bool RegisterSendCodec(AudioEncoder* send_codec) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool RegisterSendCodec(int encoder_type,
|
||||||
|
uint8_t payload_type,
|
||||||
|
int frame_size_samples = 0) OVERRIDE;
|
||||||
|
|
||||||
|
virtual const AudioEncoder* GetSenderInfo() const OVERRIDE;
|
||||||
|
|
||||||
|
virtual int Add10MsAudio(const AudioFrame& audio_frame) OVERRIDE;
|
||||||
|
|
||||||
|
virtual const ReceiverInfo* GetReceiverInfo() const OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool RegisterReceiveCodec(AudioDecoder* receive_codec) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool RegisterReceiveCodec(int decoder_type,
|
||||||
|
uint8_t payload_type) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool InsertPacket(const uint8_t* incoming_payload,
|
||||||
|
int32_t payload_len_bytes,
|
||||||
|
const WebRtcRTPHeader& rtp_info) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool InsertPayload(const uint8_t* incoming_payload,
|
||||||
|
int32_t payload_len_byte,
|
||||||
|
uint8_t payload_type,
|
||||||
|
uint32_t timestamp) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool SetMinimumPlayoutDelay(int time_ms) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool SetMaximumPlayoutDelay(int time_ms) OVERRIDE;
|
||||||
|
|
||||||
|
virtual int LeastRequiredDelayMs() const OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool PlayoutTimestamp(uint32_t* timestamp) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool Get10MsAudio(AudioFrame* audio_frame) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool NetworkStatistics(
|
||||||
|
ACMNetworkStatistics* network_statistics) OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool EnableNack(size_t max_nack_list_size) OVERRIDE;
|
||||||
|
|
||||||
|
virtual void DisableNack() OVERRIDE;
|
||||||
|
|
||||||
|
virtual std::vector<uint16_t> GetNackList(
|
||||||
|
int round_trip_time_ms) const OVERRIDE;
|
||||||
|
|
||||||
|
virtual void GetDecodingCallStatistics(
|
||||||
|
AudioDecodingCallStats* call_stats) const OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Temporary method to be used during redesign phase.
|
||||||
|
// Maps |codec_type| (a value from the anonymous enum in acm2::ACMCodecDB) to
|
||||||
|
// |codec_name|, |sample_rate_hz|, and |channels|.
|
||||||
|
// TODO(henrik.lundin) Remove this when no longer needed.
|
||||||
|
static bool MapCodecTypeToParameters(int codec_type,
|
||||||
|
std::string* codec_name,
|
||||||
|
int* sample_rate_hz,
|
||||||
|
int* channels);
|
||||||
|
|
||||||
|
scoped_ptr<acm2::AudioCodingModuleImpl> acm_old_;
|
||||||
|
int playout_frequency_hz_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_AUDIO_CODING_MODULE_IMPL_H_
|
||||||
|
Reference in New Issue
Block a user