Add get/set base min delay to neteq and acm_receiver.
Bug: webrtc:10287 Change-Id: Ia25f11eda1e2ac65e58a060c4f5332189214e189 Reviewed-on: https://webrtc-review.googlesource.com/c/121560 Commit-Queue: Ruslan Burakov <kuddai@google.com> Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26547}
This commit is contained in:

committed by
Commit Bot

parent
9f6a0d5d21
commit
9bee67c5c9
@ -58,6 +58,14 @@ int AcmReceiver::SetMaximumDelay(int delay_ms) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool AcmReceiver::SetBaseMinimumDelayMs(int delay_ms) {
|
||||
return neteq_->SetBaseMinimumDelayMs(delay_ms);
|
||||
}
|
||||
|
||||
int AcmReceiver::GetBaseMinimumDelayMs() const {
|
||||
return neteq_->GetBaseMinimumDelayMs();
|
||||
}
|
||||
|
||||
absl::optional<int> AcmReceiver::last_packet_sample_rate_hz() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (!last_decoder_) {
|
||||
|
@ -108,6 +108,16 @@ class AcmReceiver {
|
||||
//
|
||||
int SetMaximumDelay(int delay_ms);
|
||||
|
||||
// Sets a base minimum delay in milliseconds for the packet buffer.
|
||||
// Base minimum delay sets lower bound minimum delay value which
|
||||
// is set via SetMinimumDelay.
|
||||
//
|
||||
// Returns true if value was successfully set, false overwise.
|
||||
bool SetBaseMinimumDelayMs(int delay_ms);
|
||||
|
||||
// Returns current value of base minimum delay in milliseconds.
|
||||
int GetBaseMinimumDelayMs() const;
|
||||
|
||||
//
|
||||
// Resets the initial delay to zero.
|
||||
//
|
||||
|
@ -194,6 +194,16 @@ class NetEq {
|
||||
// the |max_delay_ms| value in the NetEq::Config struct.
|
||||
virtual bool SetMaximumDelay(int delay_ms) = 0;
|
||||
|
||||
// Sets a base minimum delay in milliseconds for packet buffer. The minimum
|
||||
// delay which is set via |SetMinimumDelay| can't be lower than base minimum
|
||||
// delay. Calling this method is similar to setting the |min_delay_ms| value
|
||||
// in the NetEq::Config struct. Returns true if the base minimum is
|
||||
// successfully applied, otherwise false is returned.
|
||||
virtual bool SetBaseMinimumDelayMs(int delay_ms) = 0;
|
||||
|
||||
// Returns current value of base minimum delay in milliseconds.
|
||||
virtual int GetBaseMinimumDelayMs() const = 0;
|
||||
|
||||
// Returns the current target delay in ms. This includes any extra delay
|
||||
// requested through SetMinimumDelay.
|
||||
virtual int TargetDelayMs() const = 0;
|
||||
|
@ -41,6 +41,8 @@ class MockDelayManager : public DelayManager {
|
||||
MOCK_METHOD1(UpdateCounters, void(int elapsed_time_ms));
|
||||
MOCK_METHOD0(ResetPacketIatCount, void());
|
||||
MOCK_CONST_METHOD2(BufferLimits, void(int* lower_limit, int* higher_limit));
|
||||
MOCK_METHOD1(SetBaseMinimumDelay, bool(int delay_ms));
|
||||
MOCK_CONST_METHOD0(GetBaseMinimumDelay, int());
|
||||
MOCK_CONST_METHOD0(TargetLevel, int());
|
||||
MOCK_METHOD0(RegisterEmptyPacket, void());
|
||||
MOCK_METHOD1(set_extra_delay_ms, void(int16_t delay));
|
||||
|
@ -279,6 +279,19 @@ bool NetEqImpl::SetMaximumDelay(int delay_ms) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetEqImpl::SetBaseMinimumDelayMs(int delay_ms) {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (delay_ms >= 0 && delay_ms <= 10000) {
|
||||
return delay_manager_->SetBaseMinimumDelay(delay_ms);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int NetEqImpl::GetBaseMinimumDelayMs() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return delay_manager_->GetBaseMinimumDelay();
|
||||
}
|
||||
|
||||
int NetEqImpl::TargetDelayMs() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
RTC_DCHECK(delay_manager_.get());
|
||||
|
@ -150,6 +150,10 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
|
||||
bool SetMaximumDelay(int delay_ms) override;
|
||||
|
||||
bool SetBaseMinimumDelayMs(int delay_ms) override;
|
||||
|
||||
int GetBaseMinimumDelayMs() const override;
|
||||
|
||||
int TargetDelayMs() const override;
|
||||
|
||||
int FilteredCurrentDelayMs() const override;
|
||||
|
@ -1263,6 +1263,34 @@ TEST_F(NetEqImplTest, TickTimerIncrement) {
|
||||
EXPECT_EQ(1u, tick_timer_->ticks());
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, SetBaseMinimumDelay) {
|
||||
UseNoMocks();
|
||||
use_mock_delay_manager_ = true;
|
||||
CreateInstance();
|
||||
|
||||
EXPECT_CALL(*mock_delay_manager_, SetBaseMinimumDelay(_))
|
||||
.WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
const int delay_ms = 200;
|
||||
|
||||
EXPECT_EQ(true, neteq_->SetBaseMinimumDelayMs(delay_ms));
|
||||
EXPECT_EQ(false, neteq_->SetBaseMinimumDelayMs(delay_ms));
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, GetBaseMinimumDelayMs) {
|
||||
UseNoMocks();
|
||||
use_mock_delay_manager_ = true;
|
||||
CreateInstance();
|
||||
|
||||
const int delay_ms = 200;
|
||||
|
||||
EXPECT_CALL(*mock_delay_manager_, GetBaseMinimumDelay())
|
||||
.WillOnce(Return(delay_ms));
|
||||
|
||||
EXPECT_EQ(delay_ms, neteq_->GetBaseMinimumDelayMs());
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, TargetDelayMs) {
|
||||
UseNoMocks();
|
||||
use_mock_delay_manager_ = true;
|
||||
|
Reference in New Issue
Block a user