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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 TEST_F(NetEqDecodingTest, UnknownPayloadType) { | 922 TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
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 |
| 932 #if defined(WEBRTC_ANDROID) |
| 933 #define MAYBE_DecoderError DISABLED_DecoderError |
| 934 #else |
| 935 #define MAYBE_DecoderError DecoderError |
| 936 #endif |
933 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) | 937 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
934 #define IF_ISAC(x) x | 938 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { |
935 #else | |
936 #define IF_ISAC(x) DISABLED_##x | |
937 #endif | |
938 | |
939 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) { | |
940 const size_t kPayloadBytes = 100; | 939 const size_t kPayloadBytes = 100; |
941 uint8_t payload[kPayloadBytes] = {0}; | 940 uint8_t payload[kPayloadBytes] = {0}; |
942 WebRtcRTPHeader rtp_info; | 941 WebRtcRTPHeader rtp_info; |
943 PopulateRtpInfo(0, 0, &rtp_info); | 942 PopulateRtpInfo(0, 0, &rtp_info); |
944 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. | 943 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
945 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); | 944 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
946 NetEqOutputType type; | 945 NetEqOutputType type; |
947 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 946 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
948 // to GetAudio. | 947 // to GetAudio. |
949 for (size_t i = 0; i < kMaxBlockSize; ++i) { | 948 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. | 966 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
968 EXPECT_EQ(0, out_data_[i]); | 967 EXPECT_EQ(0, out_data_[i]); |
969 } | 968 } |
970 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { | 969 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { |
971 std::ostringstream ss; | 970 std::ostringstream ss; |
972 ss << "i = " << i; | 971 ss << "i = " << i; |
973 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 972 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
974 EXPECT_EQ(1, out_data_[i]); | 973 EXPECT_EQ(1, out_data_[i]); |
975 } | 974 } |
976 } | 975 } |
| 976 #endif |
977 | 977 |
978 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { | 978 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { |
979 NetEqOutputType type; | 979 NetEqOutputType type; |
980 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 980 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
981 // to GetAudio. | 981 // to GetAudio. |
982 for (size_t i = 0; i < kMaxBlockSize; ++i) { | 982 for (size_t i = 0; i < kMaxBlockSize; ++i) { |
983 out_data_[i] = 1; | 983 out_data_[i] = 1; |
984 } | 984 } |
985 int num_channels; | 985 int num_channels; |
986 size_t samples_per_channel; | 986 size_t samples_per_channel; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 CheckBgn(16000); | 1164 CheckBgn(16000); |
1165 CheckBgn(32000); | 1165 CheckBgn(32000); |
1166 } | 1166 } |
1167 | 1167 |
1168 TEST_F(NetEqBgnTestFade, RunTest) { | 1168 TEST_F(NetEqBgnTestFade, RunTest) { |
1169 CheckBgn(8000); | 1169 CheckBgn(8000); |
1170 CheckBgn(16000); | 1170 CheckBgn(16000); |
1171 CheckBgn(32000); | 1171 CheckBgn(32000); |
1172 } | 1172 } |
1173 | 1173 |
1174 TEST_F(NetEqDecodingTest, IF_ISAC(SyncPacketInsert)) { | 1174 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
| 1175 TEST_F(NetEqDecodingTest, SyncPacketInsert) { |
1175 WebRtcRTPHeader rtp_info; | 1176 WebRtcRTPHeader rtp_info; |
1176 uint32_t receive_timestamp = 0; | 1177 uint32_t receive_timestamp = 0; |
1177 // For the readability use the following payloads instead of the defaults of | 1178 // For the readability use the following payloads instead of the defaults of |
1178 // this test. | 1179 // this test. |
1179 uint8_t kPcm16WbPayloadType = 1; | 1180 uint8_t kPcm16WbPayloadType = 1; |
1180 uint8_t kCngNbPayloadType = 2; | 1181 uint8_t kCngNbPayloadType = 2; |
1181 uint8_t kCngWbPayloadType = 3; | 1182 uint8_t kCngWbPayloadType = 3; |
1182 uint8_t kCngSwb32PayloadType = 4; | 1183 uint8_t kCngSwb32PayloadType = 4; |
1183 uint8_t kCngSwb48PayloadType = 5; | 1184 uint8_t kCngSwb48PayloadType = 5; |
1184 uint8_t kAvtPayloadType = 6; | 1185 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)); | 1244 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1244 | 1245 |
1245 // Change of SSRC is not allowed with a sync packet. | 1246 // Change of SSRC is not allowed with a sync packet. |
1246 rtp_info.header.payloadType = kPcm16WbPayloadType; | 1247 rtp_info.header.payloadType = kPcm16WbPayloadType; |
1247 ++rtp_info.header.ssrc; | 1248 ++rtp_info.header.ssrc; |
1248 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1249 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1249 | 1250 |
1250 --rtp_info.header.ssrc; | 1251 --rtp_info.header.ssrc; |
1251 EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1252 EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1252 } | 1253 } |
| 1254 #endif |
1253 | 1255 |
1254 // First insert several noise like packets, then sync-packets. Decoding all | 1256 // First insert several noise like packets, then sync-packets. Decoding all |
1255 // packets should not produce error, statistics should not show any packet loss | 1257 // packets should not produce error, statistics should not show any packet loss |
1256 // and sync-packets should decode to zero. | 1258 // and sync-packets should decode to zero. |
1257 // TODO(turajs) we will have a better test if we have a referece NetEq, and | 1259 // 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 | 1260 // when Sync packets are inserted in "test" NetEq we insert all-zero payload |
1259 // in reference NetEq and compare the output of those two. | 1261 // in reference NetEq and compare the output of those two. |
1260 TEST_F(NetEqDecodingTest, SyncPacketDecode) { | 1262 TEST_F(NetEqDecodingTest, SyncPacketDecode) { |
1261 WebRtcRTPHeader rtp_info; | 1263 WebRtcRTPHeader rtp_info; |
1262 PopulateRtpInfo(0, 0, &rtp_info); | 1264 PopulateRtpInfo(0, 0, &rtp_info); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 // Pull audio once. | 1639 // Pull audio once. |
1638 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1640 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1639 &num_channels, &type)); | 1641 &num_channels, &type)); |
1640 ASSERT_EQ(kBlockSize16kHz, out_len); | 1642 ASSERT_EQ(kBlockSize16kHz, out_len); |
1641 } | 1643 } |
1642 // Verify speech output. | 1644 // Verify speech output. |
1643 EXPECT_EQ(kOutputNormal, type); | 1645 EXPECT_EQ(kOutputNormal, type); |
1644 } | 1646 } |
1645 | 1647 |
1646 } // namespace webrtc | 1648 } // namespace webrtc |
OLD | NEW |