Reland "Remove legacy delay manger field trial and update default config."

This is a reland of 93849d4b2a976b0a46059d6f74d9efd8f12eab92

Original change's description:
> Remove legacy delay manger field trial and update default config.
>
> Bug: webrtc:10333
> Change-Id: I20e55d8d111d93657d1afe556fe3a325337c074c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232820
> Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35321}

Bug: webrtc:10333
Change-Id: I9b3c732309d32640d15c372a4dde37d5d44c95d1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237502
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35325}
This commit is contained in:
Jakob Ivarsson
2021-11-09 12:58:45 +01:00
committed by WebRTC LUCI CQ
parent 46814941f2
commit fa68ac0c4e
11 changed files with 149 additions and 298 deletions

View File

@ -1026,22 +1026,37 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
EXPECT_CALL(mock_decoder, PacketDuration(nullptr, 0))
.WillRepeatedly(Return(rtc::checked_cast<int>(kPayloadLengthSamples)));
// Pointee(x) verifies that first byte of the payload equals x, this makes it
// possible to verify that the correct payload is fed to Decode().
EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes,
kSampleRateKhz * 1000, _, _))
.WillOnce(DoAll(SetArrayArgument<3>(dummy_output,
dummy_output + kPayloadLengthSamples),
SetArgPointee<4>(AudioDecoder::kSpeech),
Return(rtc::checked_cast<int>(kPayloadLengthSamples))));
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
SdpAudioFormat("opus", 48000, 2)));
EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(1), kPayloadLengthBytes,
kSampleRateKhz * 1000, _, _))
.WillOnce(DoAll(SetArrayArgument<3>(dummy_output,
dummy_output + kPayloadLengthSamples),
SetArgPointee<4>(AudioDecoder::kComfortNoise),
Return(rtc::checked_cast<int>(kPayloadLengthSamples))));
struct Packet {
int sequence_number_delta;
int timestamp_delta;
AudioDecoder::SpeechType decoder_output_type;
};
std::vector<Packet> packets = {
{0, 0, AudioDecoder::kSpeech},
{1, kPayloadLengthSamples, AudioDecoder::kComfortNoise},
{2, 2 * kPayloadLengthSamples, AudioDecoder::kSpeech},
{1, kPayloadLengthSamples, AudioDecoder::kSpeech}};
for (size_t i = 0; i < packets.size(); ++i) {
rtp_header.sequenceNumber += packets[i].sequence_number_delta;
rtp_header.timestamp += packets[i].timestamp_delta;
payload[0] = i;
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
// Pointee(x) verifies that first byte of the payload equals x, this makes
// it possible to verify that the correct payload is fed to Decode().
EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(i), kPayloadLengthBytes,
kSampleRateKhz * 1000, _, _))
.WillOnce(DoAll(SetArrayArgument<3>(
dummy_output, dummy_output + kPayloadLengthSamples),
SetArgPointee<4>(packets[i].decoder_output_type),
Return(rtc::checked_cast<int>(kPayloadLengthSamples))));
}
// Expect comfort noise to be returned by the decoder.
EXPECT_CALL(mock_decoder,
DecodeInternal(IsNull(), 0, kSampleRateKhz * 1000, _, _))
.WillOnce(DoAll(SetArrayArgument<3>(dummy_output,
@ -1049,87 +1064,24 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
SetArgPointee<4>(AudioDecoder::kComfortNoise),
Return(rtc::checked_cast<int>(kPayloadLengthSamples))));
EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes,
kSampleRateKhz * 1000, _, _))
.WillOnce(DoAll(SetArrayArgument<3>(dummy_output,
dummy_output + kPayloadLengthSamples),
SetArgPointee<4>(AudioDecoder::kSpeech),
Return(rtc::checked_cast<int>(kPayloadLengthSamples))));
std::vector<AudioFrame::SpeechType> expected_output = {
AudioFrame::kNormalSpeech, AudioFrame::kCNG, AudioFrame::kNormalSpeech};
size_t output_index = 0;
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
SdpAudioFormat("opus", 48000, 2)));
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz);
AudioFrame output;
AudioFrame::SpeechType expected_type[8] = {
AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech, AudioFrame::kCNG,
AudioFrame::kCNG, AudioFrame::kCNG, AudioFrame::kCNG,
AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech};
int expected_timestamp_increment[8] = {
-1, // will not be used.
10 * kSampleRateKhz,
-1,
-1, // timestamp will be empty during CNG mode; indicated by -1 here.
-1,
-1,
50 * kSampleRateKhz,
10 * kSampleRateKhz};
// Insert one packet (decoder will return speech).
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
bool muted;
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
absl::optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp();
ASSERT_TRUE(last_timestamp);
// Insert second packet (decoder will return CNG).
payload[0] = 1;
rtp_header.sequenceNumber++;
rtp_header.timestamp += kPayloadLengthSamples;
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
// Lambda for verifying the timestamps.
auto verify_timestamp = [&last_timestamp, &expected_timestamp_increment](
absl::optional<uint32_t> ts, size_t i) {
if (expected_timestamp_increment[i] == -1) {
// Expect to get an empty timestamp value during CNG and PLC.
EXPECT_FALSE(ts) << "i = " << i;
int timeout_counter = 0;
while (!packet_buffer_->Empty()) {
ASSERT_LT(timeout_counter++, 20) << "Test timed out";
AudioFrame output;
bool muted;
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
if (output_index + 1 < expected_output.size() &&
output.speech_type_ == expected_output[output_index + 1]) {
++output_index;
} else {
ASSERT_TRUE(ts) << "i = " << i;
EXPECT_EQ(*ts, *last_timestamp + expected_timestamp_increment[i])
<< "i = " << i;
last_timestamp = ts;
EXPECT_EQ(output.speech_type_, expected_output[output_index]);
}
};
for (size_t i = 1; i < 6; ++i) {
ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
EXPECT_EQ(1u, output.num_channels_);
EXPECT_EQ(expected_type[i - 1], output.speech_type_);
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
SCOPED_TRACE("");
verify_timestamp(neteq_->GetPlayoutTimestamp(), i);
}
// Insert third packet, which leaves a gap from last packet.
payload[0] = 2;
rtp_header.sequenceNumber += 2;
rtp_header.timestamp += 2 * kPayloadLengthSamples;
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
for (size_t i = 6; i < 8; ++i) {
ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
EXPECT_EQ(1u, output.num_channels_);
EXPECT_EQ(expected_type[i - 1], output.speech_type_);
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
SCOPED_TRACE("");
verify_timestamp(neteq_->GetPlayoutTimestamp(), i);
}
// Now check the packet buffer, and make sure it is empty.
EXPECT_TRUE(packet_buffer_->Empty());
EXPECT_CALL(mock_decoder, Die());
}