NetEq: New test for muted state during CNG

Verifies that NetEq doesn't enter muted state when CNG mode is active
and the packet stream is suspended for a long time.

BUG=webrtc:5608

Review-Url: https://codereview.webrtc.org/2335343011
Cr-Commit-Position: refs/heads/master@{#14308}
This commit is contained in:
henrik.lundin
2016-09-20 06:51:40 -07:00
committed by Commit bot
parent d69e526440
commit 42feb51f15

View File

@ -1315,6 +1315,17 @@ class NetEqDecodingTestWithMutedState : public NetEqDecodingTest {
EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
}
void InsertCngPacket(uint32_t rtp_timestamp) {
uint8_t payload[kPayloadBytes] = {0};
WebRtcRTPHeader rtp_info;
size_t payload_len;
PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len);
EXPECT_EQ(
NetEq::kOK,
neteq_->InsertPacket(
rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0));
}
bool GetAudioReturnMuted() {
bool muted;
EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted));
@ -1429,6 +1440,39 @@ TEST_F(NetEqDecodingTestWithMutedState, MutedStateOldPacket) {
EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_);
}
// Verifies that NetEq doesn't enter muted state when CNG mode is active and the
// packet stream is suspended for a long time.
TEST_F(NetEqDecodingTestWithMutedState, DoNotMuteExtendedCngWithoutPackets) {
// Insert one CNG packet.
InsertCngPacket(0);
// Pull 10 seconds of audio (10 ms audio generated per lap).
for (int i = 0; i < 1000; ++i) {
bool muted;
EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted));
ASSERT_FALSE(muted);
}
EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_);
}
// Verifies that NetEq goes back to normal after a long CNG period with the
// packet stream suspended.
TEST_F(NetEqDecodingTestWithMutedState, RecoverAfterExtendedCngWithoutPackets) {
// Insert one CNG packet.
InsertCngPacket(0);
// Pull 10 seconds of audio (10 ms audio generated per lap).
for (int i = 0; i < 1000; ++i) {
bool muted;
EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted));
}
// Insert new data. Timestamp is corrected for the time elapsed since the last
// packet. Verify that normal operation resumes.
InsertPacket(kSamples * counter_);
GetAudioUntilNormal();
}
class NetEqDecodingTestTwoInstances : public NetEqDecodingTest {
public:
NetEqDecodingTestTwoInstances() : NetEqDecodingTest() {}