NetEq: Deprecate playout modes Fax, Off and Streaming

The playout modes other than Normal have not been reachable for a long
time, other than through tests. It is time to deprecate them.

The only meaningful use was that Fax mode was sometimes set from
tests, in order to avoid time-stretching operations (accelerate and
pre-emptive expand) from messing with the test results. With this CL,
a new config is added instead, which lets the user specify exactly
this: don't do time-stretching.

As a result of Fax and Off modes being removed, the following code
clean-up was done:
- Fold DecisionLogicNormal into DecisionLogic.
- Remove AudioRepetition and AlternativePlc operations, since they can
  no longer be reached.

Bug: webrtc:9421
Change-Id: I651458e9c1931a99f3b07e242817d303bac119df
Reviewed-on: https://webrtc-review.googlesource.com/84123
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23704}
This commit is contained in:
Henrik Lundin
2018-06-21 11:13:07 +02:00
committed by Commit Bot
parent c0260b4f2b
commit 80c4cca491
23 changed files with 479 additions and 782 deletions

View File

@ -101,7 +101,6 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
reset_decoder_(false),
ssrc_(0),
first_packet_(true),
playout_mode_(config.playout_mode),
enable_fast_accelerate_(config.enable_fast_accelerate),
nack_enabled_(false),
enable_muted_state_(config.enable_muted_state),
@ -110,7 +109,8 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
tick_timer_.get()),
speech_expand_uma_logger_("WebRTC.Audio.SpeechExpandRatePercent",
10, // Report once every 10 s.
tick_timer_.get()) {
tick_timer_.get()),
no_time_stretching_(config.for_test_no_time_stretching) {
RTC_LOG(LS_INFO) << "NetEq config: " << config.ToString();
int fs = config.sample_rate_hz;
if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) {
@ -358,23 +358,6 @@ int NetEqImpl::FilteredCurrentDelayMs() const {
return static_cast<int>(delay_samples) / rtc::CheckedDivExact(fs_hz_, 1000);
}
// Deprecated.
// TODO(henrik.lundin) Delete.
void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
rtc::CritScope lock(&crit_sect_);
if (mode != playout_mode_) {
playout_mode_ = mode;
CreateDecisionLogic();
}
}
// Deprecated.
// TODO(henrik.lundin) Delete.
NetEqPlayoutMode NetEqImpl::PlayoutMode() const {
rtc::CritScope lock(&crit_sect_);
return playout_mode_;
}
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
rtc::CritScope lock(&crit_sect_);
assert(decoder_database_.get());
@ -937,33 +920,6 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted) {
return_value = DoDtmf(dtmf_event, &play_dtmf);
break;
}
case kAlternativePlc: {
// TODO(hlundin): Write test for this.
DoAlternativePlc(false);
break;
}
case kAlternativePlcIncreaseTimestamp: {
// TODO(hlundin): Write test for this.
DoAlternativePlc(true);
break;
}
case kAudioRepetitionIncreaseTimestamp: {
// TODO(hlundin): Write test for this.
sync_buffer_->IncreaseEndTimestamp(
static_cast<uint32_t>(output_size_samples_));
// Skipping break on purpose. Execution should move on into the
// next case.
RTC_FALLTHROUGH();
}
case kAudioRepetition: {
// TODO(hlundin): Write test for this.
// Copy last |output_size_samples_| from |sync_buffer_| to
// |algorithm_buffer|.
algorithm_buffer_->PushBackFromIndex(
*sync_buffer_, sync_buffer_->Size() - output_size_samples_);
expand_->Reset();
break;
}
case kUndefined: {
RTC_LOG(LS_ERROR) << "Invalid operation kUndefined.";
assert(false); // This should not happen.
@ -1291,10 +1247,7 @@ int NetEqImpl::GetDecision(Operations* operation,
// Get packets from buffer.
int extracted_samples = 0;
if (packet && *operation != kAlternativePlc &&
*operation != kAlternativePlcIncreaseTimestamp &&
*operation != kAudioRepetition &&
*operation != kAudioRepetitionIncreaseTimestamp) {
if (packet) {
sync_buffer_->IncreaseEndTimestamp(packet->timestamp - end_timestamp);
if (decision_logic_->CngOff()) {
// Adjustment of timestamp only corresponds to an actual packet loss
@ -1883,29 +1836,6 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
return 0;
}
void NetEqImpl::DoAlternativePlc(bool increase_timestamp) {
AudioDecoder* decoder = decoder_database_->GetActiveDecoder();
size_t length;
if (decoder && decoder->HasDecodePlc()) {
// Use the decoder's packet-loss concealment.
// TODO(hlundin): Will probably need a longer buffer for multi-channel.
int16_t decoded_buffer[kMaxFrameSize];
length = decoder->DecodePlc(1, decoded_buffer);
if (length > 0)
algorithm_buffer_->PushBackInterleaved(decoded_buffer, length);
} else {
// Do simple zero-stuffing.
length = output_size_samples_;
algorithm_buffer_->Zeros(length);
// By not advancing the timestamp, NetEq inserts samples.
stats_.AddZeros(length);
}
if (increase_timestamp) {
sync_buffer_->IncreaseEndTimestamp(static_cast<uint32_t>(length));
}
expand_->Reset();
}
int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event,
size_t num_channels,
int16_t* output) const {
@ -2130,8 +2060,8 @@ NetEqImpl::OutputType NetEqImpl::LastOutputType() {
void NetEqImpl::CreateDecisionLogic() {
decision_logic_.reset(DecisionLogic::Create(
fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(),
*packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(),
tick_timer_.get()));
fs_hz_, output_size_samples_, no_time_stretching_,
decoder_database_.get(), *packet_buffer_.get(), delay_manager_.get(),
buffer_level_filter_.get(), tick_timer_.get()));
}
} // namespace webrtc