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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_unittest.cc

Issue 1532903002: Reenables several NetEq unittests on android. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed review comments. Created 5 years 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 unified diff | Download patch
OLDNEW
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
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 #ifndef WEBRTC_CODEC_ISAC
412 // Ignore payload type 104 (iSAC-swb) if ISAC is not supported.
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
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
521 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { 524 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) {
522 const std::string input_rtp_file = webrtc::test::ProjectRootPath() + 525 const std::string input_rtp_file = webrtc::test::ProjectRootPath() +
523 "resources/audio_coding/neteq_universal_new.rtp"; 526 "resources/audio_coding/neteq_universal_new.rtp";
524 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm 527 // 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 528 // are identical. The latter could have been removed, but if clients still
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 const size_t kPayloadBytes = 100; 893 const size_t kPayloadBytes = 100;
891 uint8_t payload[kPayloadBytes] = {0}; 894 uint8_t payload[kPayloadBytes] = {0};
892 WebRtcRTPHeader rtp_info; 895 WebRtcRTPHeader rtp_info;
893 PopulateRtpInfo(0, 0, &rtp_info); 896 PopulateRtpInfo(0, 0, &rtp_info);
894 rtp_info.header.payloadType = 1; // Not registered as a decoder. 897 rtp_info.header.payloadType = 1; // Not registered as a decoder.
895 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); 898 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0));
896 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); 899 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
897 } 900 }
898 901
899 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 902 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
900 #define IF_ISAC(x) x 903 #define MAYBE_DecoderError DecoderError
901 #else 904 #else
902 #define IF_ISAC(x) DISABLED_##x 905 #define MAYBE_DecoderError DISABLED_DecoderError
903 #endif 906 #endif
904 907
905 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) { 908 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) {
906 const size_t kPayloadBytes = 100; 909 const size_t kPayloadBytes = 100;
907 uint8_t payload[kPayloadBytes] = {0}; 910 uint8_t payload[kPayloadBytes] = {0};
908 WebRtcRTPHeader rtp_info; 911 WebRtcRTPHeader rtp_info;
909 PopulateRtpInfo(0, 0, &rtp_info); 912 PopulateRtpInfo(0, 0, &rtp_info);
910 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. 913 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid.
911 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); 914 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
912 NetEqOutputType type; 915 NetEqOutputType type;
913 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call 916 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call
914 // to GetAudio. 917 // to GetAudio.
915 for (size_t i = 0; i < kMaxBlockSize; ++i) { 918 for (size_t i = 0; i < kMaxBlockSize; ++i) {
916 out_data_[i] = 1; 919 out_data_[i] = 1;
917 } 920 }
918 int num_channels; 921 int num_channels;
919 size_t samples_per_channel; 922 size_t samples_per_channel;
920 EXPECT_EQ(NetEq::kFail, 923 EXPECT_EQ(NetEq::kFail,
921 neteq_->GetAudio(kMaxBlockSize, out_data_, 924 neteq_->GetAudio(kMaxBlockSize, out_data_,
922 &samples_per_channel, &num_channels, &type)); 925 &samples_per_channel, &num_channels, &type));
923 // Verify that there is a decoder error to check. 926 // Verify that there is a decoder error to check.
924 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); 927 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError());
925 // Code 6730 is an iSAC error code. 928
926 EXPECT_EQ(6730, neteq_->LastDecoderError()); 929 enum NetEqDecoderError {
930 ISAC_LENGTH_MISMATCH = 6730,
931 ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH = 6640
932 };
933 #if defined(WEBRTC_CODEC_ISAC)
934 EXPECT_EQ(ISAC_LENGTH_MISMATCH, neteq_->LastDecoderError());
935 #elif defined(WEBRTC_CODEC_ISACFX)
936 EXPECT_EQ(ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH, neteq_->LastDecoderError());
937 #endif
927 // Verify that the first 160 samples are set to 0, and that the remaining 938 // Verify that the first 160 samples are set to 0, and that the remaining
928 // samples are left unmodified. 939 // samples are left unmodified.
929 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. 940 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate.
930 for (int i = 0; i < kExpectedOutputLength; ++i) { 941 for (int i = 0; i < kExpectedOutputLength; ++i) {
931 std::ostringstream ss; 942 std::ostringstream ss;
932 ss << "i = " << i; 943 ss << "i = " << i;
933 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. 944 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
934 EXPECT_EQ(0, out_data_[i]); 945 EXPECT_EQ(0, out_data_[i]);
935 } 946 }
936 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { 947 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 CheckBgn(16000); 1141 CheckBgn(16000);
1131 CheckBgn(32000); 1142 CheckBgn(32000);
1132 } 1143 }
1133 1144
1134 TEST_F(NetEqBgnTestFade, RunTest) { 1145 TEST_F(NetEqBgnTestFade, RunTest) {
1135 CheckBgn(8000); 1146 CheckBgn(8000);
1136 CheckBgn(16000); 1147 CheckBgn(16000);
1137 CheckBgn(32000); 1148 CheckBgn(32000);
1138 } 1149 }
1139 1150
1140 TEST_F(NetEqDecodingTest, IF_ISAC(SyncPacketInsert)) { 1151 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
1152 #define MAYBE_SyncPacketInsert SyncPacketInsert
1153 #else
1154 #define MAYBE_SyncPacketInsert DISABLED_SyncPacketInsert
1155 #endif
1156 TEST_F(NetEqDecodingTest, MAYBE_SyncPacketInsert) {
1141 WebRtcRTPHeader rtp_info; 1157 WebRtcRTPHeader rtp_info;
1142 uint32_t receive_timestamp = 0; 1158 uint32_t receive_timestamp = 0;
1143 // For the readability use the following payloads instead of the defaults of 1159 // For the readability use the following payloads instead of the defaults of
1144 // this test. 1160 // this test.
1145 uint8_t kPcm16WbPayloadType = 1; 1161 uint8_t kPcm16WbPayloadType = 1;
1146 uint8_t kCngNbPayloadType = 2; 1162 uint8_t kCngNbPayloadType = 2;
1147 uint8_t kCngWbPayloadType = 3; 1163 uint8_t kCngWbPayloadType = 3;
1148 uint8_t kCngSwb32PayloadType = 4; 1164 uint8_t kCngSwb32PayloadType = 4;
1149 uint8_t kCngSwb48PayloadType = 5; 1165 uint8_t kCngSwb48PayloadType = 5;
1150 uint8_t kAvtPayloadType = 6; 1166 uint8_t kAvtPayloadType = 6;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 // Pull audio once. 1619 // Pull audio once.
1604 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, 1620 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
1605 &num_channels, &type)); 1621 &num_channels, &type));
1606 ASSERT_EQ(kBlockSize16kHz, out_len); 1622 ASSERT_EQ(kBlockSize16kHz, out_len);
1607 } 1623 }
1608 // Verify speech output. 1624 // Verify speech output.
1609 EXPECT_EQ(kOutputNormal, type); 1625 EXPECT_EQ(kOutputNormal, type);
1610 } 1626 }
1611 1627
1612 } // namespace webrtc 1628 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698