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:
@ -14,6 +14,8 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/units/time_delta.h"
|
||||
#include "modules/audio_coding/codecs/cng/webrtc_cng.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
@ -55,6 +57,8 @@ class AudioEncoderCng 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;
|
||||
|
||||
private:
|
||||
EncodedInfo EncodePassive(size_t frames_to_encode, rtc::Buffer* encoded);
|
||||
@ -225,6 +229,11 @@ void AudioEncoderCng::OnReceivedUplinkBandwidth(
|
||||
bwe_period_ms);
|
||||
}
|
||||
|
||||
absl::optional<std::pair<TimeDelta, TimeDelta>>
|
||||
AudioEncoderCng::GetFrameLengthRange() const {
|
||||
return speech_encoder_->GetFrameLengthRange();
|
||||
}
|
||||
|
||||
AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
|
||||
size_t frames_to_encode,
|
||||
rtc::Buffer* encoded) {
|
||||
|
||||
@ -21,8 +21,11 @@
|
||||
#include "test/testsupport/rtc_expect_death.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Eq;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Not;
|
||||
using ::testing::Optional;
|
||||
using ::testing::Return;
|
||||
using ::testing::SetArgPointee;
|
||||
|
||||
@ -233,6 +236,15 @@ TEST_F(AudioEncoderCngTest, CheckPacketLossFractionPropagation) {
|
||||
cng_->OnReceivedUplinkPacketLossFraction(0.5);
|
||||
}
|
||||
|
||||
TEST_F(AudioEncoderCngTest, CheckGetFrameLengthRangePropagation) {
|
||||
CreateCng(MakeCngConfig());
|
||||
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(cng_->GetFrameLengthRange(), Optional(Eq(expected_range)));
|
||||
}
|
||||
|
||||
TEST_F(AudioEncoderCngTest, EncodeCallsVad) {
|
||||
EXPECT_CALL(*mock_encoder_, Num10MsFramesInNextPacket())
|
||||
.WillRepeatedly(Return(1U));
|
||||
|
||||
Reference in New Issue
Block a user