Delete VAD methods from AcmReceiver and move functionality inside NetEq
This change essentially does two things: 1. Remove the VAD-related methods from AcmReceiver. These are EnableVad(), DisableVad(), and vad_enabled(). None of them were used outside of unit tests. 2. Move the functionality to set AudioFrame::speech_type_ and AudioFrame::vad_activity_ inside NetEq. This was previously done in AcmReceiver, but based on information inherently owned by NetEq. With the change in 2, NetEq's GetAudio interface can be simplified by removing the output type parameter. This will be done in a follow-up CL. BUG=webrtc:5607 Review URL: https://codereview.webrtc.org/1772583002 Cr-Commit-Position: refs/heads/master@{#11902}
This commit is contained in:
committed by
Commit bot
parent
5249599a9b
commit
500c04bc86
@ -35,77 +35,6 @@ namespace acm2 {
|
||||
|
||||
namespace {
|
||||
|
||||
// |vad_activity_| field of |audio_frame| is set to |previous_audio_activity_|
|
||||
// before the call to this function.
|
||||
void SetAudioFrameActivityAndType(bool vad_enabled,
|
||||
NetEqOutputType type,
|
||||
AudioFrame* audio_frame) {
|
||||
if (vad_enabled) {
|
||||
switch (type) {
|
||||
case kOutputNormal: {
|
||||
audio_frame->vad_activity_ = AudioFrame::kVadActive;
|
||||
audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
|
||||
break;
|
||||
}
|
||||
case kOutputVADPassive: {
|
||||
audio_frame->vad_activity_ = AudioFrame::kVadPassive;
|
||||
audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
|
||||
break;
|
||||
}
|
||||
case kOutputCNG: {
|
||||
audio_frame->vad_activity_ = AudioFrame::kVadPassive;
|
||||
audio_frame->speech_type_ = AudioFrame::kCNG;
|
||||
break;
|
||||
}
|
||||
case kOutputPLC: {
|
||||
// Don't change |audio_frame->vad_activity_|, it should be the same as
|
||||
// |previous_audio_activity_|.
|
||||
audio_frame->speech_type_ = AudioFrame::kPLC;
|
||||
break;
|
||||
}
|
||||
case kOutputPLCtoCNG: {
|
||||
audio_frame->vad_activity_ = AudioFrame::kVadPassive;
|
||||
audio_frame->speech_type_ = AudioFrame::kPLCCNG;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
} else {
|
||||
// Always return kVadUnknown when receive VAD is inactive
|
||||
audio_frame->vad_activity_ = AudioFrame::kVadUnknown;
|
||||
switch (type) {
|
||||
case kOutputNormal: {
|
||||
audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
|
||||
break;
|
||||
}
|
||||
case kOutputCNG: {
|
||||
audio_frame->speech_type_ = AudioFrame::kCNG;
|
||||
break;
|
||||
}
|
||||
case kOutputPLC: {
|
||||
audio_frame->speech_type_ = AudioFrame::kPLC;
|
||||
break;
|
||||
}
|
||||
case kOutputPLCtoCNG: {
|
||||
audio_frame->speech_type_ = AudioFrame::kPLCCNG;
|
||||
break;
|
||||
}
|
||||
case kOutputVADPassive: {
|
||||
// Normally, we should no get any VAD decision if post-decoding VAD is
|
||||
// not active. However, if post-decoding VAD has been active then
|
||||
// disabled, we might be here for couple of frames.
|
||||
audio_frame->speech_type_ = AudioFrame::kNormalSpeech;
|
||||
LOG(WARNING) << "Post-decoding VAD is disabled but output is "
|
||||
<< "labeled VAD-passive";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Is the given codec a CNG codec?
|
||||
// TODO(kwiberg): Move to RentACodec.
|
||||
bool IsCng(int codec_id) {
|
||||
@ -120,10 +49,8 @@ bool IsCng(int codec_id) {
|
||||
|
||||
AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config)
|
||||
: last_audio_decoder_(nullptr),
|
||||
previous_audio_activity_(AudioFrame::kVadPassive),
|
||||
last_audio_buffer_(new int16_t[AudioFrame::kMaxDataSizeSamples]),
|
||||
neteq_(NetEq::Create(config.neteq_config)),
|
||||
vad_enabled_(config.neteq_config.enable_post_decode_vad),
|
||||
clock_(config.clock),
|
||||
resampled_last_output_frame_(true) {
|
||||
assert(clock_);
|
||||
@ -264,10 +191,6 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
|
||||
sizeof(int16_t) * audio_frame->samples_per_channel_ *
|
||||
audio_frame->num_channels_);
|
||||
|
||||
// Should set |vad_activity| before calling SetAudioFrameActivityAndType().
|
||||
audio_frame->vad_activity_ = previous_audio_activity_;
|
||||
SetAudioFrameActivityAndType(vad_enabled_, type, audio_frame);
|
||||
previous_audio_activity_ = audio_frame->vad_activity_;
|
||||
call_stats_.DecodedByNetEq(audio_frame->speech_type_);
|
||||
|
||||
// Computes the RTP timestamp of the first sample in |audio_frame| from
|
||||
@ -351,18 +274,6 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AcmReceiver::EnableVad() {
|
||||
neteq_->EnableVad();
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
vad_enabled_ = true;
|
||||
}
|
||||
|
||||
void AcmReceiver::DisableVad() {
|
||||
neteq_->DisableVad();
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
vad_enabled_ = false;
|
||||
}
|
||||
|
||||
void AcmReceiver::FlushBuffers() {
|
||||
neteq_->FlushBuffers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user