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 12 matching lines...) Expand all Loading... |
23 #include <string> | 23 #include <string> |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include "gflags/gflags.h" | 26 #include "gflags/gflags.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "webrtc/base/scoped_ptr.h" | 28 #include "webrtc/base/scoped_ptr.h" |
29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
30 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" | 30 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
31 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" | 31 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
32 #include "webrtc/test/testsupport/fileutils.h" | 32 #include "webrtc/test/testsupport/fileutils.h" |
33 #include "webrtc/test/testsupport/gtest_disable.h" | |
34 #include "webrtc/typedefs.h" | 33 #include "webrtc/typedefs.h" |
35 | 34 |
36 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 35 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
37 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 36 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
38 #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" | 37 #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" |
39 #else | 38 #else |
40 #include "webrtc/audio_coding/neteq/neteq_unittest.pb.h" | 39 #include "webrtc/audio_coding/neteq/neteq_unittest.pb.h" |
41 #endif | 40 #endif |
42 #endif | 41 #endif |
43 | 42 |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 const size_t kPayloadBytes = 100; | 923 const size_t kPayloadBytes = 100; |
925 uint8_t payload[kPayloadBytes] = {0}; | 924 uint8_t payload[kPayloadBytes] = {0}; |
926 WebRtcRTPHeader rtp_info; | 925 WebRtcRTPHeader rtp_info; |
927 PopulateRtpInfo(0, 0, &rtp_info); | 926 PopulateRtpInfo(0, 0, &rtp_info); |
928 rtp_info.header.payloadType = 1; // Not registered as a decoder. | 927 rtp_info.header.payloadType = 1; // Not registered as a decoder. |
929 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); | 928 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
930 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 929 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
931 } | 930 } |
932 | 931 |
933 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) | 932 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
934 #define IF_ISAC(x) x | 933 #if defined(WEBRTC_ANDROID) |
| 934 TEST_F(NetEqDecodingTest, DISABLED_DecoderError) { |
935 #else | 935 #else |
936 #define IF_ISAC(x) DISABLED_##x | 936 TEST_F(NetEqDecodingTest, DecoderError) { |
937 #endif | 937 #endif |
938 | |
939 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) { | |
940 const size_t kPayloadBytes = 100; | 938 const size_t kPayloadBytes = 100; |
941 uint8_t payload[kPayloadBytes] = {0}; | 939 uint8_t payload[kPayloadBytes] = {0}; |
942 WebRtcRTPHeader rtp_info; | 940 WebRtcRTPHeader rtp_info; |
943 PopulateRtpInfo(0, 0, &rtp_info); | 941 PopulateRtpInfo(0, 0, &rtp_info); |
944 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. | 942 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
945 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); | 943 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
946 NetEqOutputType type; | 944 NetEqOutputType type; |
947 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 945 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
948 // to GetAudio. | 946 // to GetAudio. |
949 for (size_t i = 0; i < kMaxBlockSize; ++i) { | 947 for (size_t i = 0; i < kMaxBlockSize; ++i) { |
(...skipping 17 matching lines...) Expand all Loading... |
967 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 965 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
968 EXPECT_EQ(0, out_data_[i]); | 966 EXPECT_EQ(0, out_data_[i]); |
969 } | 967 } |
970 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { | 968 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { |
971 std::ostringstream ss; | 969 std::ostringstream ss; |
972 ss << "i = " << i; | 970 ss << "i = " << i; |
973 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 971 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
974 EXPECT_EQ(1, out_data_[i]); | 972 EXPECT_EQ(1, out_data_[i]); |
975 } | 973 } |
976 } | 974 } |
| 975 #endif |
977 | 976 |
978 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { | 977 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { |
979 NetEqOutputType type; | 978 NetEqOutputType type; |
980 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 979 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
981 // to GetAudio. | 980 // to GetAudio. |
982 for (size_t i = 0; i < kMaxBlockSize; ++i) { | 981 for (size_t i = 0; i < kMaxBlockSize; ++i) { |
983 out_data_[i] = 1; | 982 out_data_[i] = 1; |
984 } | 983 } |
985 int num_channels; | 984 int num_channels; |
986 size_t samples_per_channel; | 985 size_t samples_per_channel; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 CheckBgn(16000); | 1163 CheckBgn(16000); |
1165 CheckBgn(32000); | 1164 CheckBgn(32000); |
1166 } | 1165 } |
1167 | 1166 |
1168 TEST_F(NetEqBgnTestFade, RunTest) { | 1167 TEST_F(NetEqBgnTestFade, RunTest) { |
1169 CheckBgn(8000); | 1168 CheckBgn(8000); |
1170 CheckBgn(16000); | 1169 CheckBgn(16000); |
1171 CheckBgn(32000); | 1170 CheckBgn(32000); |
1172 } | 1171 } |
1173 | 1172 |
1174 TEST_F(NetEqDecodingTest, IF_ISAC(SyncPacketInsert)) { | 1173 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
| 1174 TEST_F(NetEqDecodingTest, SyncPacketInsert) { |
1175 WebRtcRTPHeader rtp_info; | 1175 WebRtcRTPHeader rtp_info; |
1176 uint32_t receive_timestamp = 0; | 1176 uint32_t receive_timestamp = 0; |
1177 // For the readability use the following payloads instead of the defaults of | 1177 // For the readability use the following payloads instead of the defaults of |
1178 // this test. | 1178 // this test. |
1179 uint8_t kPcm16WbPayloadType = 1; | 1179 uint8_t kPcm16WbPayloadType = 1; |
1180 uint8_t kCngNbPayloadType = 2; | 1180 uint8_t kCngNbPayloadType = 2; |
1181 uint8_t kCngWbPayloadType = 3; | 1181 uint8_t kCngWbPayloadType = 3; |
1182 uint8_t kCngSwb32PayloadType = 4; | 1182 uint8_t kCngSwb32PayloadType = 4; |
1183 uint8_t kCngSwb48PayloadType = 5; | 1183 uint8_t kCngSwb48PayloadType = 5; |
1184 uint8_t kAvtPayloadType = 6; | 1184 uint8_t kAvtPayloadType = 6; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1243 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1244 | 1244 |
1245 // Change of SSRC is not allowed with a sync packet. | 1245 // Change of SSRC is not allowed with a sync packet. |
1246 rtp_info.header.payloadType = kPcm16WbPayloadType; | 1246 rtp_info.header.payloadType = kPcm16WbPayloadType; |
1247 ++rtp_info.header.ssrc; | 1247 ++rtp_info.header.ssrc; |
1248 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1248 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1249 | 1249 |
1250 --rtp_info.header.ssrc; | 1250 --rtp_info.header.ssrc; |
1251 EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1251 EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1252 } | 1252 } |
| 1253 #endif |
1253 | 1254 |
1254 // First insert several noise like packets, then sync-packets. Decoding all | 1255 // First insert several noise like packets, then sync-packets. Decoding all |
1255 // packets should not produce error, statistics should not show any packet loss | 1256 // packets should not produce error, statistics should not show any packet loss |
1256 // and sync-packets should decode to zero. | 1257 // and sync-packets should decode to zero. |
1257 // TODO(turajs) we will have a better test if we have a referece NetEq, and | 1258 // TODO(turajs) we will have a better test if we have a referece NetEq, and |
1258 // when Sync packets are inserted in "test" NetEq we insert all-zero payload | 1259 // when Sync packets are inserted in "test" NetEq we insert all-zero payload |
1259 // in reference NetEq and compare the output of those two. | 1260 // in reference NetEq and compare the output of those two. |
1260 TEST_F(NetEqDecodingTest, SyncPacketDecode) { | 1261 TEST_F(NetEqDecodingTest, SyncPacketDecode) { |
1261 WebRtcRTPHeader rtp_info; | 1262 WebRtcRTPHeader rtp_info; |
1262 PopulateRtpInfo(0, 0, &rtp_info); | 1263 PopulateRtpInfo(0, 0, &rtp_info); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 // Pull audio once. | 1638 // Pull audio once. |
1638 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1639 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1639 &num_channels, &type)); | 1640 &num_channels, &type)); |
1640 ASSERT_EQ(kBlockSize16kHz, out_len); | 1641 ASSERT_EQ(kBlockSize16kHz, out_len); |
1641 } | 1642 } |
1642 // Verify speech output. | 1643 // Verify speech output. |
1643 EXPECT_EQ(kOutputNormal, type); | 1644 EXPECT_EQ(kOutputNormal, type); |
1644 } | 1645 } |
1645 | 1646 |
1646 } // namespace webrtc | 1647 } // namespace webrtc |
OLD | NEW |