Delete ACMVADCallback
This callback is enabled via the method AudioCodingModule::RegisterVADCallback, which is unused, and deleted in this cl. Bug: None Change-Id: I04c8690fbb673305e69fe5b1c32d88efd6c72d1b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148420 Reviewed-by: Minyue Li <minyue@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30735}
This commit is contained in:
@ -63,14 +63,6 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
// Set target packet loss rate
|
||||
int SetPacketLossRate(int loss_rate) override;
|
||||
|
||||
/////////////////////////////////////////
|
||||
// (VAD) Voice Activity Detection
|
||||
// and
|
||||
// (CNG) Comfort Noise Generation
|
||||
//
|
||||
|
||||
int RegisterVADCallback(ACMVADCallback* vad_callback) override;
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Receiver
|
||||
//
|
||||
@ -188,7 +180,6 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
rtc::CriticalSection callback_crit_sect_;
|
||||
AudioPacketizationCallback* packetization_callback_
|
||||
RTC_GUARDED_BY(callback_crit_sect_);
|
||||
ACMVADCallback* vad_callback_ RTC_GUARDED_BY(callback_crit_sect_);
|
||||
|
||||
int codec_histogram_bins_log_[static_cast<size_t>(
|
||||
AudioEncoder::CodecType::kMaxLoggedAudioCodecTypes)];
|
||||
@ -223,7 +214,6 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(
|
||||
first_10ms_data_(false),
|
||||
first_frame_(true),
|
||||
packetization_callback_(NULL),
|
||||
vad_callback_(NULL),
|
||||
codec_histogram_bins_log_(),
|
||||
number_of_consecutive_empty_packets_(0) {
|
||||
if (InitializeReceiverSafe() < 0) {
|
||||
@ -313,11 +303,6 @@ int32_t AudioCodingModuleImpl::Encode(
|
||||
encode_buffer_.data(), encode_buffer_.size(),
|
||||
absolute_capture_timestamp_ms.value_or(-1));
|
||||
}
|
||||
|
||||
if (vad_callback_) {
|
||||
// Callback with VAD decision.
|
||||
vad_callback_->InFrameType(frame_type);
|
||||
}
|
||||
}
|
||||
previous_pltype_ = encoded_info.payload_type;
|
||||
return static_cast<int32_t>(encode_buffer_.size());
|
||||
@ -596,13 +581,6 @@ int AudioCodingModuleImpl::GetNetworkStatistics(NetworkStatistics* statistics) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AudioCodingModuleImpl::RegisterVADCallback(ACMVADCallback* vad_callback) {
|
||||
RTC_LOG(LS_VERBOSE) << "RegisterVADCallback()";
|
||||
rtc::CritScope lock(&callback_crit_sect_);
|
||||
vad_callback_ = vad_callback;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {
|
||||
if (!encoder_stack_) {
|
||||
RTC_LOG(LS_ERROR) << caller_name << " failed: No send codec is registered.";
|
||||
|
||||
@ -61,14 +61,6 @@ class AudioPacketizationCallback {
|
||||
}
|
||||
};
|
||||
|
||||
// Callback class used for reporting VAD decision
|
||||
class ACMVADCallback {
|
||||
public:
|
||||
virtual ~ACMVADCallback() {}
|
||||
|
||||
virtual int32_t InFrameType(AudioFrameType frame_type) = 0;
|
||||
};
|
||||
|
||||
class AudioCodingModule {
|
||||
protected:
|
||||
AudioCodingModule() {}
|
||||
@ -162,26 +154,6 @@ class AudioCodingModule {
|
||||
// TODO(minyue): Remove it when possible.
|
||||
virtual int SetPacketLossRate(int packet_loss_rate) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// (VAD) Voice Activity Detection
|
||||
//
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int32_t RegisterVADCallback()
|
||||
// Call this method to register a callback function which is called
|
||||
// any time that ACM encounters an empty frame. That is a frame which is
|
||||
// recognized inactive. Depending on the codec WebRtc VAD or internal codec
|
||||
// VAD is employed to identify a frame as active/inactive.
|
||||
//
|
||||
// Input:
|
||||
// -vad_callback : pointer to a callback function.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed to register the callback function.
|
||||
// 0 if the callback function is registered successfully.
|
||||
//
|
||||
virtual int32_t RegisterVADCallback(ACMVADCallback* vad_callback) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Receiver
|
||||
//
|
||||
|
||||
@ -29,16 +29,25 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ActivityMonitor::ActivityMonitor() {
|
||||
MonitoringAudioPacketizationCallback::MonitoringAudioPacketizationCallback(
|
||||
AudioPacketizationCallback* next)
|
||||
: next_(next) {
|
||||
ResetStatistics();
|
||||
}
|
||||
|
||||
int32_t ActivityMonitor::InFrameType(AudioFrameType frame_type) {
|
||||
int32_t MonitoringAudioPacketizationCallback::SendData(
|
||||
AudioFrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_len_bytes,
|
||||
int64_t absolute_capture_timestamp_ms) {
|
||||
counter_[static_cast<int>(frame_type)]++;
|
||||
return 0;
|
||||
return next_->SendData(frame_type, payload_type, timestamp, payload_data,
|
||||
payload_len_bytes, absolute_capture_timestamp_ms);
|
||||
}
|
||||
|
||||
void ActivityMonitor::PrintStatistics() {
|
||||
void MonitoringAudioPacketizationCallback::PrintStatistics() {
|
||||
printf("\n");
|
||||
printf("kEmptyFrame %u\n",
|
||||
counter_[static_cast<int>(AudioFrameType::kEmptyFrame)]);
|
||||
@ -49,11 +58,11 @@ void ActivityMonitor::PrintStatistics() {
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
void ActivityMonitor::ResetStatistics() {
|
||||
void MonitoringAudioPacketizationCallback::ResetStatistics() {
|
||||
memset(counter_, 0, sizeof(counter_));
|
||||
}
|
||||
|
||||
void ActivityMonitor::GetStatistics(uint32_t* counter) {
|
||||
void MonitoringAudioPacketizationCallback::GetStatistics(uint32_t* counter) {
|
||||
memcpy(counter, counter_, sizeof(counter_));
|
||||
}
|
||||
|
||||
@ -68,11 +77,13 @@ TestVadDtx::TestVadDtx()
|
||||
AudioCodingModule::Config(decoder_factory_))),
|
||||
acm_receive_(AudioCodingModule::Create(
|
||||
AudioCodingModule::Config(decoder_factory_))),
|
||||
channel_(new Channel),
|
||||
monitor_(new ActivityMonitor) {
|
||||
EXPECT_EQ(0, acm_send_->RegisterTransportCallback(channel_.get()));
|
||||
channel_(std::make_unique<Channel>()),
|
||||
packetization_callback_(
|
||||
std::make_unique<MonitoringAudioPacketizationCallback>(
|
||||
channel_.get())) {
|
||||
EXPECT_EQ(
|
||||
0, acm_send_->RegisterTransportCallback(packetization_callback_.get()));
|
||||
channel_->RegisterReceiverACM(acm_receive_.get());
|
||||
EXPECT_EQ(0, acm_send_->RegisterVADCallback(monitor_.get()));
|
||||
}
|
||||
|
||||
bool TestVadDtx::RegisterCodec(const SdpAudioFormat& codec_format,
|
||||
@ -109,7 +120,7 @@ void TestVadDtx::Run(std::string in_filename,
|
||||
std::string out_filename,
|
||||
bool append,
|
||||
const int* expects) {
|
||||
monitor_->ResetStatistics();
|
||||
packetization_callback_->ResetStatistics();
|
||||
|
||||
PCMFile in_file;
|
||||
in_file.Open(in_filename, frequency, "rb");
|
||||
@ -144,12 +155,12 @@ void TestVadDtx::Run(std::string in_filename,
|
||||
out_file.Close();
|
||||
|
||||
#ifdef PRINT_STAT
|
||||
monitor_->PrintStatistics();
|
||||
packetization_callback_->PrintStatistics();
|
||||
#endif
|
||||
|
||||
uint32_t stats[3];
|
||||
monitor_->GetStatistics(stats);
|
||||
monitor_->ResetStatistics();
|
||||
packetization_callback_->GetStatistics(stats);
|
||||
packetization_callback_->ResetStatistics();
|
||||
|
||||
for (const auto& st : stats) {
|
||||
int i = &st - stats; // Calculate the current position in stats.
|
||||
|
||||
@ -22,10 +22,20 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ActivityMonitor : public ACMVADCallback {
|
||||
// This class records the frame type, and delegates actual sending to the
|
||||
// |next_| AudioPacketizationCallback.
|
||||
class MonitoringAudioPacketizationCallback : public AudioPacketizationCallback {
|
||||
public:
|
||||
ActivityMonitor();
|
||||
int32_t InFrameType(AudioFrameType frame_type);
|
||||
explicit MonitoringAudioPacketizationCallback(
|
||||
AudioPacketizationCallback* next);
|
||||
|
||||
int32_t SendData(AudioFrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_len_bytes,
|
||||
int64_t absolute_capture_timestamp_ms) override;
|
||||
|
||||
void PrintStatistics();
|
||||
void ResetStatistics();
|
||||
void GetStatistics(uint32_t* stats);
|
||||
@ -35,6 +45,7 @@ class ActivityMonitor : public ACMVADCallback {
|
||||
// 1 - kAudioFrameSpeech
|
||||
// 2 - kAudioFrameCN
|
||||
uint32_t counter_[3];
|
||||
AudioPacketizationCallback* const next_;
|
||||
};
|
||||
|
||||
// TestVadDtx is to verify that VAD/DTX perform as they should. It runs through
|
||||
@ -74,7 +85,7 @@ class TestVadDtx {
|
||||
std::unique_ptr<AudioCodingModule> acm_send_;
|
||||
std::unique_ptr<AudioCodingModule> acm_receive_;
|
||||
std::unique_ptr<Channel> channel_;
|
||||
std::unique_ptr<ActivityMonitor> monitor_;
|
||||
std::unique_ptr<MonitoringAudioPacketizationCallback> packetization_callback_;
|
||||
uint32_t time_stamp_ = 0x12345678;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user