Implement AudioEncoder::GetFrameLengthRange() for all audio encoders.

The WebRTC-SendSideBwe-WithOverhead field trial requires audio
encoders to properly implement the
AudioEncoder::GetFrameLengthRange() function. Thic CL implements
the function for all audio encoders in WebRTC in preparation for
making that function pure virtual in the interface.


Bug: webrtc:11427
Change-Id: Ieab6b6c72c62af6ac9525a20fcb39bd477079551
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171503
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30890}
This commit is contained in:
Ali Tofigh
2020-03-24 16:00:51 +01:00
committed by Commit Bot
parent d4262dffa0
commit 7e5dfdbca3
16 changed files with 108 additions and 0 deletions

View File

@ -132,4 +132,9 @@ void AudioEncoderCopyRed::OnReceivedUplinkBandwidth(
bwe_period_ms);
}
absl::optional<std::pair<TimeDelta, TimeDelta>>
AudioEncoderCopyRed::GetFrameLengthRange() const {
return speech_encoder_->GetFrameLengthRange();
}
} // namespace webrtc

View File

@ -15,10 +15,12 @@
#include <stdint.h>
#include <memory>
#include <utility>
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/audio_codecs/audio_encoder.h"
#include "api/units/time_delta.h"
#include "rtc_base/buffer.h"
#include "rtc_base/constructor_magic.h"
@ -60,6 +62,8 @@ class AudioEncoderCopyRed final : public AudioEncoder {
void OnReceivedUplinkBandwidth(
int target_audio_bitrate_bps,
absl::optional<int64_t> bwe_period_ms) override;
absl::optional<std::pair<TimeDelta, TimeDelta>> GetFrameLengthRange()
const override;
protected:
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,

View File

@ -20,9 +20,12 @@
#include "test/testsupport/rtc_expect_death.h"
using ::testing::_;
using ::testing::Eq;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::MockFunction;
using ::testing::Not;
using ::testing::Optional;
using ::testing::Return;
using ::testing::SetArgPointee;
@ -107,6 +110,14 @@ TEST_F(AudioEncoderCopyRedTest, CheckPacketLossFractionPropagation) {
red_->OnReceivedUplinkPacketLossFraction(0.5);
}
TEST_F(AudioEncoderCopyRedTest, CheckGetFrameLengthRangePropagation) {
auto expected_range =
std::make_pair(TimeDelta::Millis(20), TimeDelta::Millis(20));
EXPECT_CALL(*mock_encoder_, GetFrameLengthRange())
.WillRepeatedly(Return(absl::make_optional(expected_range)));
EXPECT_THAT(red_->GetFrameLengthRange(), Optional(Eq(expected_range)));
}
// Checks that the an Encode() call is immediately propagated to the speech
// encoder.
TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) {