OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 neteq_internal_.reset(NetEq::Create(config)); | 181 neteq_internal_.reset(NetEq::Create(config)); |
182 } | 182 } |
183 | 183 |
184 void SetUp() override { | 184 void SetUp() override { |
185 ASSERT_EQ(NetEq::kOK, neteq_internal_->RegisterPayloadType( | 185 ASSERT_EQ(NetEq::kOK, neteq_internal_->RegisterPayloadType( |
186 NetEqDecoder::kDecoderPCM16Bswb32kHz, | 186 NetEqDecoder::kDecoderPCM16Bswb32kHz, |
187 "pcm16-swb32", kPayloadType)); | 187 "pcm16-swb32", kPayloadType)); |
188 } | 188 } |
189 | 189 |
190 void GetAndVerifyOutput() override { | 190 void GetAndVerifyOutput() override { |
191 NetEqOutputType output_type; | |
192 // Get audio from internal decoder instance. | 191 // Get audio from internal decoder instance. |
193 EXPECT_EQ(NetEq::kOK, | 192 EXPECT_EQ(NetEq::kOK, neteq_internal_->GetAudio(&output_internal_)); |
194 neteq_internal_->GetAudio(&output_internal_, &output_type)); | |
195 EXPECT_EQ(1u, output_internal_.num_channels_); | 193 EXPECT_EQ(1u, output_internal_.num_channels_); |
196 EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000), | 194 EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000), |
197 output_internal_.samples_per_channel_); | 195 output_internal_.samples_per_channel_); |
198 | 196 |
199 // Get audio from external decoder instance. | 197 // Get audio from external decoder instance. |
200 GetOutputAudio(&output_, &output_type); | 198 GetOutputAudio(&output_); |
201 | 199 |
202 for (size_t i = 0; i < output_.samples_per_channel_; ++i) { | 200 for (size_t i = 0; i < output_.samples_per_channel_; ++i) { |
203 ASSERT_EQ(output_.data_[i], output_internal_.data_[i]) | 201 ASSERT_EQ(output_.data_[i], output_internal_.data_[i]) |
204 << "Diff in sample " << i << "."; | 202 << "Diff in sample " << i << "."; |
205 } | 203 } |
206 } | 204 } |
207 | 205 |
208 void InsertPacket(WebRtcRTPHeader rtp_header, | 206 void InsertPacket(WebRtcRTPHeader rtp_header, |
209 rtc::ArrayView<const uint8_t> payload, | 207 rtc::ArrayView<const uint8_t> payload, |
210 uint32_t receive_timestamp) override { | 208 uint32_t receive_timestamp) override { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 }; | 242 }; |
245 | 243 |
246 LargeTimestampJumpTest() | 244 LargeTimestampJumpTest() |
247 : NetEqExternalDecoderUnitTest(NetEqDecoder::kDecoderPCM16B, | 245 : NetEqExternalDecoderUnitTest(NetEqDecoder::kDecoderPCM16B, |
248 new MockExternalPcm16B), | 246 new MockExternalPcm16B), |
249 test_state_(kInitialPhase) { | 247 test_state_(kInitialPhase) { |
250 EXPECT_CALL(*external_decoder(), HasDecodePlc()) | 248 EXPECT_CALL(*external_decoder(), HasDecodePlc()) |
251 .WillRepeatedly(Return(false)); | 249 .WillRepeatedly(Return(false)); |
252 } | 250 } |
253 | 251 |
254 virtual void UpdateState(NetEqOutputType output_type) { | 252 virtual void UpdateState(AudioFrame::SpeechType output_type) { |
255 switch (test_state_) { | 253 switch (test_state_) { |
256 case kInitialPhase: { | 254 case kInitialPhase: { |
257 if (output_type == kOutputNormal) { | 255 if (output_type == AudioFrame::kNormalSpeech) { |
258 test_state_ = kNormalPhase; | 256 test_state_ = kNormalPhase; |
259 } | 257 } |
260 break; | 258 break; |
261 } | 259 } |
262 case kNormalPhase: { | 260 case kNormalPhase: { |
263 if (output_type == kOutputPLC) { | 261 if (output_type == AudioFrame::kPLC) { |
264 test_state_ = kExpandPhase; | 262 test_state_ = kExpandPhase; |
265 } | 263 } |
266 break; | 264 break; |
267 } | 265 } |
268 case kExpandPhase: { | 266 case kExpandPhase: { |
269 if (output_type == kOutputPLCtoCNG) { | 267 if (output_type == AudioFrame::kPLCCNG) { |
270 test_state_ = kFadedExpandPhase; | 268 test_state_ = kFadedExpandPhase; |
271 } else if (output_type == kOutputNormal) { | 269 } else if (output_type == AudioFrame::kNormalSpeech) { |
272 test_state_ = kRecovered; | 270 test_state_ = kRecovered; |
273 } | 271 } |
274 break; | 272 break; |
275 } | 273 } |
276 case kFadedExpandPhase: { | 274 case kFadedExpandPhase: { |
277 if (output_type == kOutputNormal) { | 275 if (output_type == AudioFrame::kNormalSpeech) { |
278 test_state_ = kRecovered; | 276 test_state_ = kRecovered; |
279 } | 277 } |
280 break; | 278 break; |
281 } | 279 } |
282 case kRecovered: { | 280 case kRecovered: { |
283 break; | 281 break; |
284 } | 282 } |
285 } | 283 } |
286 } | 284 } |
287 | 285 |
288 void GetAndVerifyOutput() override { | 286 void GetAndVerifyOutput() override { |
289 AudioFrame output; | 287 AudioFrame output; |
290 NetEqOutputType output_type; | 288 GetOutputAudio(&output); |
291 GetOutputAudio(&output, &output_type); | 289 UpdateState(output.speech_type_); |
292 UpdateState(output_type); | |
293 | 290 |
294 if (test_state_ == kExpandPhase || test_state_ == kFadedExpandPhase) { | 291 if (test_state_ == kExpandPhase || test_state_ == kFadedExpandPhase) { |
295 // Don't verify the output in this phase of the test. | 292 // Don't verify the output in this phase of the test. |
296 return; | 293 return; |
297 } | 294 } |
298 | 295 |
299 ASSERT_EQ(1u, output.num_channels_); | 296 ASSERT_EQ(1u, output.num_channels_); |
300 for (size_t i = 0; i < output.samples_per_channel_; ++i) { | 297 for (size_t i = 0; i < output.samples_per_channel_; ++i) { |
301 if (output.data_[i] != 0) | 298 if (output.data_[i] != 0) |
302 return; | 299 return; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 kStartTimestamp, | 359 kStartTimestamp, |
363 kJumpFromTimestamp, | 360 kJumpFromTimestamp, |
364 kJumpToTimestamp)); | 361 kJumpToTimestamp)); |
365 | 362 |
366 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. | 363 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. |
367 EXPECT_EQ(kRecovered, test_state_); | 364 EXPECT_EQ(kRecovered, test_state_); |
368 } | 365 } |
369 | 366 |
370 class ShortTimestampJumpTest : public LargeTimestampJumpTest { | 367 class ShortTimestampJumpTest : public LargeTimestampJumpTest { |
371 protected: | 368 protected: |
372 void UpdateState(NetEqOutputType output_type) override { | 369 void UpdateState(AudioFrame::SpeechType output_type) override { |
373 switch (test_state_) { | 370 switch (test_state_) { |
374 case kInitialPhase: { | 371 case kInitialPhase: { |
375 if (output_type == kOutputNormal) { | 372 if (output_type == AudioFrame::kNormalSpeech) { |
376 test_state_ = kNormalPhase; | 373 test_state_ = kNormalPhase; |
377 } | 374 } |
378 break; | 375 break; |
379 } | 376 } |
380 case kNormalPhase: { | 377 case kNormalPhase: { |
381 if (output_type == kOutputPLC) { | 378 if (output_type == AudioFrame::kPLC) { |
382 test_state_ = kExpandPhase; | 379 test_state_ = kExpandPhase; |
383 } | 380 } |
384 break; | 381 break; |
385 } | 382 } |
386 case kExpandPhase: { | 383 case kExpandPhase: { |
387 if (output_type == kOutputNormal) { | 384 if (output_type == AudioFrame::kNormalSpeech) { |
388 test_state_ = kRecovered; | 385 test_state_ = kRecovered; |
389 } | 386 } |
390 break; | 387 break; |
391 } | 388 } |
392 case kRecovered: { | 389 case kRecovered: { |
393 break; | 390 break; |
394 } | 391 } |
395 default: { FAIL(); } | 392 default: { FAIL(); } |
396 } | 393 } |
397 } | 394 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 kStartSeqeunceNumber, | 441 kStartSeqeunceNumber, |
445 kStartTimestamp, | 442 kStartTimestamp, |
446 kJumpFromTimestamp, | 443 kJumpFromTimestamp, |
447 kJumpToTimestamp)); | 444 kJumpToTimestamp)); |
448 | 445 |
449 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. | 446 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. |
450 EXPECT_EQ(kRecovered, test_state_); | 447 EXPECT_EQ(kRecovered, test_state_); |
451 } | 448 } |
452 | 449 |
453 } // namespace webrtc | 450 } // namespace webrtc |
OLD | NEW |