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

Unified Diff: webrtc/voice_engine/voe_codec_unittest.cc

Issue 2177263002: Regression test for issue where Opus DTX status was being forgotten. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed GetOpusDtx to GetOpusDtxStatus to avoid naming conflict with FakeWebRtcVoiceEngine. Created 4 years, 5 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 | « webrtc/voice_engine/voe_codec_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/voe_codec_unittest.cc
diff --git a/webrtc/voice_engine/voe_codec_unittest.cc b/webrtc/voice_engine/voe_codec_unittest.cc
index 73e576bf51db50c10cfb0d794142aa79f3bf90e9..c056ba07e36cf6fd63719dacbace569b033c50ea 100644
--- a/webrtc/voice_engine/voe_codec_unittest.cc
+++ b/webrtc/voice_engine/voe_codec_unittest.cc
@@ -22,85 +22,6 @@ namespace webrtc {
namespace voe {
namespace {
-class VoECodecTest : public ::testing::Test {
- protected:
- VoECodecTest()
- : voe_(VoiceEngine::Create()),
- base_(VoEBase::GetInterface(voe_)),
- voe_codec_(VoECodec::GetInterface(voe_)),
- channel_(-1),
- adm_(new FakeAudioDeviceModule),
- red_payload_type_(-1) {}
-
- ~VoECodecTest() {}
-
- void TearDown() {
- base_->DeleteChannel(channel_);
- base_->Terminate();
- base_->Release();
- voe_codec_->Release();
- VoiceEngine::Delete(voe_);
- }
-
- void SetUp() {
- // Check if all components are valid.
- ASSERT_TRUE(voe_ != NULL);
- ASSERT_TRUE(base_ != NULL);
- ASSERT_TRUE(voe_codec_ != NULL);
- ASSERT_TRUE(adm_.get() != NULL);
- ASSERT_EQ(0, base_->Init(adm_.get()));
- channel_ = base_->CreateChannel();
- ASSERT_NE(-1, channel_);
-
- CodecInst my_codec;
-
- bool primary_found = false;
- bool valid_secondary_found = false;
- bool invalid_secondary_found = false;
-
- // Find primary and secondary codecs.
- int num_codecs = voe_codec_->NumOfCodecs();
- int n = 0;
- while (n < num_codecs &&
- (!primary_found || !valid_secondary_found ||
- !invalid_secondary_found || red_payload_type_ < 0)) {
- EXPECT_EQ(0, voe_codec_->GetCodec(n, my_codec));
- if (!STR_CASE_CMP(my_codec.plname, "isac") && my_codec.plfreq == 16000) {
- memcpy(&valid_secondary_, &my_codec, sizeof(my_codec));
- valid_secondary_found = true;
- } else if (!STR_CASE_CMP(my_codec.plname, "isac") &&
- my_codec.plfreq == 32000) {
- memcpy(&invalid_secondary_, &my_codec, sizeof(my_codec));
- invalid_secondary_found = true;
- } else if (!STR_CASE_CMP(my_codec.plname, "L16") &&
- my_codec.plfreq == 16000) {
- memcpy(&primary_, &my_codec, sizeof(my_codec));
- primary_found = true;
- } else if (!STR_CASE_CMP(my_codec.plname, "RED")) {
- red_payload_type_ = my_codec.pltype;
- }
- n++;
- }
-
- EXPECT_TRUE(primary_found);
- EXPECT_TRUE(valid_secondary_found);
- EXPECT_TRUE(invalid_secondary_found);
- EXPECT_NE(-1, red_payload_type_);
- }
-
- VoiceEngine* voe_;
- VoEBase* base_;
- VoECodec* voe_codec_;
- int channel_;
- CodecInst primary_;
- CodecInst valid_secondary_;
- std::unique_ptr<FakeAudioDeviceModule> adm_;
-
- // A codec which is not valid to be registered as secondary codec.
- CodecInst invalid_secondary_;
- int red_payload_type_;
-};
-
TEST(VoECodecInst, TestCompareCodecInstances) {
CodecInst codec1, codec2;
memset(&codec1, 0, sizeof(CodecInst));
@@ -151,6 +72,36 @@ TEST(VoECodecInst, TestCompareCodecInstances) {
EXPECT_FALSE(codec1 == codec2);
}
+// This is a regression test for
+// https://bugs.chromium.org/p/webrtc/issues/detail?id=6020
+// The Opus DTX setting was being forgotten after unrelated VoE calls.
+TEST(VoECodecInst, RememberOpusDtxAfterSettingChange) {
+ VoiceEngine* voe(VoiceEngine::Create());
+ VoEBase* base(VoEBase::GetInterface(voe));
+ VoECodec* voe_codec(VoECodec::GetInterface(voe));
+ std::unique_ptr<FakeAudioDeviceModule> adm(new FakeAudioDeviceModule);
+
+ base->Init(adm.get());
+
+ CodecInst codec = {111, "opus", 48000, 960, 1, 32000};
+
+ int channel = base->CreateChannel();
+
+ bool DTX = false;
+
+ EXPECT_EQ(0, voe_codec->SetSendCodec(channel, codec));
+ EXPECT_EQ(0, voe_codec->SetOpusDtx(channel, true));
+ EXPECT_EQ(0, voe_codec->SetFECStatus(channel, true));
+ EXPECT_EQ(0, voe_codec->GetOpusDtxStatus(channel, &DTX));
+ EXPECT_TRUE(DTX);
+
+ base->DeleteChannel(channel);
+ base->Terminate();
+ base->Release();
+ voe_codec->Release();
+ VoiceEngine::Delete(voe);
+}
+
} // namespace
} // namespace voe
} // namespace webrtc
« no previous file with comments | « webrtc/voice_engine/voe_codec_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698