NetEq: Implement Expand::Muted
Adding a new method to the Expand class, which will answer the question whether an ongoing expansion has been faded down to zero amplitude (i.e., been muted). Also adding a test. This new functionality will be used in CLs to follow. BUG=webrtc:5608 NOTRY=True Review-Url: https://codereview.webrtc.org/1967473004 Cr-Commit-Position: refs/heads/master@{#12672}
This commit is contained in:
parent
60f6ce2a29
commit
f3995f71ce
@ -327,6 +327,17 @@ void Expand::SetParametersForMergeAfterExpand() {
|
||||
stop_muting_ = true;
|
||||
}
|
||||
|
||||
bool Expand::Muted() const {
|
||||
if (first_expand_ || stop_muting_)
|
||||
return false;
|
||||
RTC_DCHECK(channel_parameters_);
|
||||
for (size_t ch = 0; ch < num_channels_; ++ch) {
|
||||
if (channel_parameters_[ch].mute_factor != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Expand::overlap_length() const {
|
||||
return overlap_length_;
|
||||
}
|
||||
|
||||
@ -62,6 +62,10 @@ class Expand {
|
||||
return channel_parameters_[channel].mute_factor;
|
||||
}
|
||||
|
||||
// Returns true if expansion has been faded down to zero amplitude (for all
|
||||
// channels); false otherwise.
|
||||
bool Muted() const;
|
||||
|
||||
// Accessors and mutators.
|
||||
virtual size_t overlap_length() const;
|
||||
size_t max_lag() const { return max_lag_; }
|
||||
|
||||
@ -169,6 +169,37 @@ TEST_F(ExpandTest, CheckOutageStatsAfterReset) {
|
||||
statistics_.last_outage_duration_ms());
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Runs expand until Muted() returns true. Times out after 1000 calls.
|
||||
void ExpandUntilMuted(size_t num_channels, Expand* expand) {
|
||||
EXPECT_FALSE(expand->Muted()) << "Instance is muted from the start";
|
||||
AudioMultiVector output(num_channels);
|
||||
int num_calls = 0;
|
||||
while (!expand->Muted()) {
|
||||
ASSERT_LT(num_calls++, 1000) << "Test timed out";
|
||||
EXPECT_EQ(0, expand->Process(&output));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Verifies that Muted() returns true after a long expand period. Also verifies
|
||||
// that Muted() is reset to false after calling Reset(),
|
||||
// SetParametersForMergeAfterExpand() and SetParametersForNormalAfterExpand().
|
||||
TEST_F(ExpandTest, Muted) {
|
||||
ExpandUntilMuted(num_channels_, &expand_);
|
||||
expand_.Reset();
|
||||
EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted.
|
||||
|
||||
ExpandUntilMuted(num_channels_, &expand_);
|
||||
expand_.SetParametersForMergeAfterExpand();
|
||||
EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted.
|
||||
|
||||
expand_.Reset(); // Must reset in order to start a new expand period.
|
||||
ExpandUntilMuted(num_channels_, &expand_);
|
||||
expand_.SetParametersForNormalAfterExpand();
|
||||
EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted.
|
||||
}
|
||||
|
||||
// TODO(hlundin): Write more tests.
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user