OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 break; | 130 break; |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 // Following is the implementation of TestWebRtcVadDtx. | 136 // Following is the implementation of TestWebRtcVadDtx. |
137 TestWebRtcVadDtx::TestWebRtcVadDtx() | 137 TestWebRtcVadDtx::TestWebRtcVadDtx() |
138 : vad_enabled_(false), | 138 : vad_enabled_(false), |
139 dtx_enabled_(false), | 139 dtx_enabled_(false), |
140 use_webrtc_dtx_(false), | |
141 output_file_num_(0) { | 140 output_file_num_(0) { |
142 } | 141 } |
143 | 142 |
144 void TestWebRtcVadDtx::Perform() { | 143 void TestWebRtcVadDtx::Perform() { |
145 // Go through various test cases. | 144 // Go through various test cases. |
146 #ifdef WEBRTC_CODEC_ISAC | 145 #ifdef WEBRTC_CODEC_ISAC |
147 // Register iSAC WB as send codec | 146 // Register iSAC WB as send codec |
148 RegisterCodec(kIsacWb); | 147 RegisterCodec(kIsacWb); |
149 RunTestCases(); | 148 RunTestCases(); |
150 | 149 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 SetVAD(true, true, VADVeryAggr); | 183 SetVAD(true, true, VADVeryAggr); |
185 Test(false); | 184 Test(false); |
186 | 185 |
187 // #5 DTX = ON, VAD = ON, VADNormal | 186 // #5 DTX = ON, VAD = ON, VADNormal |
188 SetVAD(true, true, VADNormal); | 187 SetVAD(true, true, VADNormal); |
189 Test(false); | 188 Test(false); |
190 } | 189 } |
191 | 190 |
192 // Set the expectation and run the test. | 191 // Set the expectation and run the test. |
193 void TestWebRtcVadDtx::Test(bool new_outfile) { | 192 void TestWebRtcVadDtx::Test(bool new_outfile) { |
194 int expects[] = {-1, 1, use_webrtc_dtx_, 0, 0}; | 193 int expects[] = {-1, 1, dtx_enabled_, 0, 0}; |
195 if (new_outfile) { | 194 if (new_outfile) { |
196 output_file_num_++; | 195 output_file_num_++; |
197 } | 196 } |
198 std::stringstream out_filename; | 197 std::stringstream out_filename; |
199 out_filename << webrtc::test::OutputPath() | 198 out_filename << webrtc::test::OutputPath() |
200 << "testWebRtcVadDtx_outFile_" | 199 << "testWebRtcVadDtx_outFile_" |
201 << output_file_num_ | 200 << output_file_num_ |
202 << ".pcm"; | 201 << ".pcm"; |
203 Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), | 202 Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), |
204 32000, 1, out_filename.str(), !new_outfile, expects); | 203 32000, 1, out_filename.str(), !new_outfile, expects); |
205 } | 204 } |
206 | 205 |
207 void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad, | 206 void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad, |
208 ACMVADMode vad_mode) { | 207 ACMVADMode vad_mode) { |
209 ACMVADMode mode; | 208 ACMVADMode mode; |
210 EXPECT_EQ(0, acm_send_->SetVAD(enable_dtx, enable_vad, vad_mode)); | 209 EXPECT_EQ(0, acm_send_->SetVAD(enable_dtx, enable_vad, vad_mode)); |
211 EXPECT_EQ(0, acm_send_->VAD(&dtx_enabled_, &vad_enabled_, &mode)); | 210 EXPECT_EQ(0, acm_send_->VAD(&dtx_enabled_, &vad_enabled_, &mode)); |
212 | 211 |
213 CodecInst codec_param; | 212 CodecInst codec_param; |
214 acm_send_->SendCodec(&codec_param); | 213 acm_send_->SendCodec(&codec_param); |
215 if (STR_CASE_CMP(codec_param.plname, "opus") == 0) { | 214 if (STR_CASE_CMP(codec_param.plname, "opus") == 0) { |
216 // If send codec is Opus, WebRTC VAD/DTX cannot be used. | 215 // If send codec is Opus, WebRTC VAD/DTX cannot be used. |
217 enable_dtx = enable_vad = false; | 216 enable_dtx = enable_vad = false; |
218 } | 217 } |
219 | 218 |
220 EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected. | 219 EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected. |
221 | 220 |
222 bool replaced = false; | 221 if (dtx_enabled_) { |
223 acm_send_->IsInternalDTXReplacedWithWebRtc(&replaced); | |
224 | |
225 use_webrtc_dtx_ = dtx_enabled_ && replaced; | |
226 | |
227 if (use_webrtc_dtx_) { | |
228 EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD. | 222 EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD. |
229 } | 223 } else { |
230 | 224 // Using no DTX should not affect setting of VAD. |
231 if (!dtx_enabled_ || !use_webrtc_dtx_) { | |
232 // Using no DTX or codec Internal DTX should not affect setting of VAD. | |
233 EXPECT_EQ(enable_vad, vad_enabled_); | 225 EXPECT_EQ(enable_vad, vad_enabled_); |
234 } | 226 } |
235 } | 227 } |
236 | 228 |
237 // Following is the implementation of TestOpusDtx. | 229 // Following is the implementation of TestOpusDtx. |
238 void TestOpusDtx::Perform() { | 230 void TestOpusDtx::Perform() { |
239 #ifdef WEBRTC_CODEC_ISAC | 231 #ifdef WEBRTC_CODEC_ISAC |
240 // If we set other codec than Opus, DTX cannot be toggled. | 232 // If we set other codec than Opus, DTX cannot be toggled. |
241 RegisterCodec(kIsacWb); | 233 RegisterCodec(kIsacWb); |
242 EXPECT_EQ(-1, acm_send_->EnableOpusDtx()); | 234 EXPECT_EQ(-1, acm_send_->EnableOpusDtx()); |
(...skipping 27 matching lines...) Expand all Loading... |
270 | 262 |
271 EXPECT_EQ(0, acm_send_->EnableOpusDtx()); | 263 EXPECT_EQ(0, acm_send_->EnableOpusDtx()); |
272 | 264 |
273 expects[kFrameEmpty] = 1; | 265 expects[kFrameEmpty] = 1; |
274 Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), | 266 Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), |
275 32000, 2, out_filename, true, expects); | 267 32000, 2, out_filename, true, expects); |
276 #endif | 268 #endif |
277 } | 269 } |
278 | 270 |
279 } // namespace webrtc | 271 } // namespace webrtc |
OLD | NEW |