Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc

Issue 1331853002: ACM CodecOwner: Test that we reset speech encoder when enabling CNG or RED (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@mark
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc b/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
index ec1bb0df2be12bb488232789eef10db2a8b031df..9c1707333942639914f71d4c539aaf7659c23b9c 100644
--- a/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
@@ -56,6 +56,41 @@ class CodecOwnerTest : public ::testing::Test {
encoded_info.send_even_if_empty);
}
+ // Verify that the speech encoder's Reset method is called when CNG or RED
+ // (or both) are switched on, but not when they're switched off.
+ void TestCngAndRedResetSpeechEncoder(bool use_cng, bool use_red) {
+ MockAudioEncoder speech_encoder;
+ EXPECT_CALL(speech_encoder, NumChannels())
+ .WillRepeatedly(Return(1));
+ EXPECT_CALL(speech_encoder, Max10MsFramesInAPacket())
+ .WillRepeatedly(Return(2));
+ EXPECT_CALL(speech_encoder, SampleRateHz())
+ .WillRepeatedly(Return(8000));
+ {
+ InSequence s;
+ EXPECT_CALL(speech_encoder, Mark("start off"));
+ EXPECT_CALL(speech_encoder, Mark("switch on"));
+ if (use_cng || use_red)
+ EXPECT_CALL(speech_encoder, Reset());
+ EXPECT_CALL(speech_encoder, Mark("start on"));
+ if (use_cng || use_red)
+ EXPECT_CALL(speech_encoder, Reset());
+ EXPECT_CALL(speech_encoder, Mark("switch off"));
+ EXPECT_CALL(speech_encoder, Die());
+ }
+
+ int cng_pt = use_cng ? 17 : -1;
+ int red_pt = use_red ? 19 : -1;
+ speech_encoder.Mark("start off");
+ codec_owner_.SetEncoders(&speech_encoder, -1, VADNormal, -1);
+ speech_encoder.Mark("switch on");
+ codec_owner_.ChangeCngAndRed(cng_pt, VADNormal, red_pt);
+ speech_encoder.Mark("start on");
+ codec_owner_.SetEncoders(&speech_encoder, cng_pt, VADNormal, red_pt);
+ speech_encoder.Mark("switch off");
+ codec_owner_.ChangeCngAndRed(-1, VADNormal, -1);
+ }
+
CodecOwner codec_owner_;
uint32_t timestamp_;
};
@@ -145,5 +180,21 @@ TEST_F(CodecOwnerTest, ExternalEncoder) {
EXPECT_EQ(2u, info.encoded_timestamp);
}
+TEST_F(CodecOwnerTest, CngResetsSpeechEncoder) {
+ TestCngAndRedResetSpeechEncoder(true, false);
+}
+
+TEST_F(CodecOwnerTest, RedResetsSpeechEncoder) {
+ TestCngAndRedResetSpeechEncoder(false, true);
+}
+
+TEST_F(CodecOwnerTest, CngAndRedResetsSpeechEncoder) {
+ TestCngAndRedResetSpeechEncoder(true, true);
+}
+
+TEST_F(CodecOwnerTest, NoCngAndRedNoSpeechEncoderReset) {
+ TestCngAndRedResetSpeechEncoder(false, false);
+}
+
} // namespace acm2
} // namespace webrtc
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698