OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) { | 401 void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) { |
402 rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); | 402 rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); |
403 } | 403 } |
404 | 404 |
405 void NetEqDecodingTest::Process(size_t* out_len) { | 405 void NetEqDecodingTest::Process(size_t* out_len) { |
406 // Check if time to receive. | 406 // Check if time to receive. |
407 while (packet_ && sim_clock_ >= packet_->time_ms()) { | 407 while (packet_ && sim_clock_ >= packet_->time_ms()) { |
408 if (packet_->payload_length_bytes() > 0) { | 408 if (packet_->payload_length_bytes() > 0) { |
409 WebRtcRTPHeader rtp_header; | 409 WebRtcRTPHeader rtp_header; |
410 packet_->ConvertHeader(&rtp_header); | 410 packet_->ConvertHeader(&rtp_header); |
411 #ifdef WEBRTC_ANDROID | |
412 // Payload type 104 is not supported on android. | |
413 if (rtp_header.header.payloadType != 104) | |
414 #endif | |
411 ASSERT_EQ(0, neteq_->InsertPacket( | 415 ASSERT_EQ(0, neteq_->InsertPacket( |
412 rtp_header, | 416 rtp_header, |
413 rtc::ArrayView<const uint8_t>( | 417 rtc::ArrayView<const uint8_t>( |
414 packet_->payload(), packet_->payload_length_bytes()), | 418 packet_->payload(), packet_->payload_length_bytes()), |
415 static_cast<uint32_t>(packet_->time_ms() * | 419 static_cast<uint32_t>(packet_->time_ms() * |
416 (output_sample_rate_ / 1000)))); | 420 (output_sample_rate_ / 1000)))); |
417 } | 421 } |
418 // Get next packet. | 422 // Get next packet. |
419 packet_.reset(rtp_source_->NextPacket()); | 423 packet_.reset(rtp_source_->NextPacket()); |
420 } | 424 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 size_t* payload_len) { | 507 size_t* payload_len) { |
504 rtp_info->header.sequenceNumber = frame_index; | 508 rtp_info->header.sequenceNumber = frame_index; |
505 rtp_info->header.timestamp = timestamp; | 509 rtp_info->header.timestamp = timestamp; |
506 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. | 510 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. |
507 rtp_info->header.payloadType = 98; // WB CNG. | 511 rtp_info->header.payloadType = 98; // WB CNG. |
508 rtp_info->header.markerBit = 0; | 512 rtp_info->header.markerBit = 0; |
509 payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. | 513 payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. |
510 *payload_len = 1; // Only noise level, no spectral parameters. | 514 *payload_len = 1; // Only noise level, no spectral parameters. |
511 } | 515 } |
512 | 516 |
513 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) && \ | 517 #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ |
514 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ | 518 (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ |
515 (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ | |
516 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) | 519 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) |
517 #define MAYBE_TestBitExactness TestBitExactness | 520 #define MAYBE_TestBitExactness TestBitExactness |
518 #else | 521 #else |
519 #define MAYBE_TestBitExactness DISABLED_TestBitExactness | 522 #define MAYBE_TestBitExactness DISABLED_TestBitExactness |
520 #endif | 523 #endif |
524 | |
521 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { | 525 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { |
522 const std::string input_rtp_file = webrtc::test::ProjectRootPath() + | 526 const std::string input_rtp_file = webrtc::test::ProjectRootPath() + |
523 "resources/audio_coding/neteq_universal_new.rtp"; | 527 "resources/audio_coding/neteq_universal_new.rtp"; |
524 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm | 528 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm |
525 // are identical. The latter could have been removed, but if clients still | 529 // are identical. The latter could have been removed, but if clients still |
526 // have a copy of the file, the test will fail. | 530 // have a copy of the file, the test will fail. |
527 const std::string input_ref_file = | 531 const std::string input_ref_file = |
528 webrtc::test::ResourcePath("audio_coding/neteq4_universal_ref", "pcm"); | 532 webrtc::test::ResourcePath("audio_coding/neteq4_universal_ref", "pcm"); |
529 #if defined(_MSC_VER) && (_MSC_VER >= 1700) | 533 #if defined(_MSC_VER) && (_MSC_VER >= 1700) |
530 // For Visual Studio 2012 and later, we will have to use the generic reference | 534 // For Visual Studio 2012 and later, we will have to use the generic reference |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); | 899 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
896 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 900 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
897 } | 901 } |
898 | 902 |
899 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) | 903 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
900 #define IF_ISAC(x) x | 904 #define IF_ISAC(x) x |
901 #else | 905 #else |
902 #define IF_ISAC(x) DISABLED_##x | 906 #define IF_ISAC(x) DISABLED_##x |
903 #endif | 907 #endif |
904 | 908 |
905 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) { | 909 TEST_F(NetEqDecodingTest, IF_ISAC(DecoderError)) { |
minyue-webrtc
2015/12/17 14:32:58
may you change this to MAYBE_?
#if defined(WEBRTC
ivoc
2015/12/17 15:06:28
Good idea, done.
| |
906 const size_t kPayloadBytes = 100; | 910 const size_t kPayloadBytes = 100; |
907 uint8_t payload[kPayloadBytes] = {0}; | 911 uint8_t payload[kPayloadBytes] = {0}; |
908 WebRtcRTPHeader rtp_info; | 912 WebRtcRTPHeader rtp_info; |
909 PopulateRtpInfo(0, 0, &rtp_info); | 913 PopulateRtpInfo(0, 0, &rtp_info); |
910 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. | 914 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
911 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); | 915 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
912 NetEqOutputType type; | 916 NetEqOutputType type; |
913 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 917 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
914 // to GetAudio. | 918 // to GetAudio. |
915 for (size_t i = 0; i < kMaxBlockSize; ++i) { | 919 for (size_t i = 0; i < kMaxBlockSize; ++i) { |
916 out_data_[i] = 1; | 920 out_data_[i] = 1; |
917 } | 921 } |
918 int num_channels; | 922 int num_channels; |
919 size_t samples_per_channel; | 923 size_t samples_per_channel; |
920 EXPECT_EQ(NetEq::kFail, | 924 EXPECT_EQ(NetEq::kFail, |
921 neteq_->GetAudio(kMaxBlockSize, out_data_, | 925 neteq_->GetAudio(kMaxBlockSize, out_data_, |
922 &samples_per_channel, &num_channels, &type)); | 926 &samples_per_channel, &num_channels, &type)); |
923 // Verify that there is a decoder error to check. | 927 // Verify that there is a decoder error to check. |
924 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); | 928 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); |
925 // Code 6730 is an iSAC error code. | 929 |
930 #if defined(WEBRTC_CODEC_ISAC) | |
926 EXPECT_EQ(6730, neteq_->LastDecoderError()); | 931 EXPECT_EQ(6730, neteq_->LastDecoderError()); |
minyue-webrtc
2015/12/17 14:32:58
would you use enum (see below) or const for these
ivoc
2015/12/17 15:06:28
Thanks for the suggestion, looks more clear.
| |
932 #else | |
minyue-webrtc
2015/12/17 14:32:58
maybe use
#elif defined(WEBRTC_CODEC_ISACFX)
ivoc
2015/12/17 15:06:27
Done.
| |
933 EXPECT_EQ(6640, neteq_->LastDecoderError()); | |
934 #endif | |
927 // Verify that the first 160 samples are set to 0, and that the remaining | 935 // Verify that the first 160 samples are set to 0, and that the remaining |
928 // samples are left unmodified. | 936 // samples are left unmodified. |
929 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. | 937 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. |
930 for (int i = 0; i < kExpectedOutputLength; ++i) { | 938 for (int i = 0; i < kExpectedOutputLength; ++i) { |
931 std::ostringstream ss; | 939 std::ostringstream ss; |
932 ss << "i = " << i; | 940 ss << "i = " << i; |
933 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 941 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
934 EXPECT_EQ(0, out_data_[i]); | 942 EXPECT_EQ(0, out_data_[i]); |
935 } | 943 } |
936 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { | 944 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1603 // Pull audio once. | 1611 // Pull audio once. |
1604 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1612 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1605 &num_channels, &type)); | 1613 &num_channels, &type)); |
1606 ASSERT_EQ(kBlockSize16kHz, out_len); | 1614 ASSERT_EQ(kBlockSize16kHz, out_len); |
1607 } | 1615 } |
1608 // Verify speech output. | 1616 // Verify speech output. |
1609 EXPECT_EQ(kOutputNormal, type); | 1617 EXPECT_EQ(kOutputNormal, type); |
1610 } | 1618 } |
1611 | 1619 |
1612 } // namespace webrtc | 1620 } // namespace webrtc |
OLD | NEW |