OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
11 #include <string.h> | 11 #include <string.h> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/base/md5digest.h" | 15 #include "webrtc/base/md5digest.h" |
16 #include "webrtc/base/scoped_ptr.h" | 16 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/base/thread_annotations.h" | 17 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
19 #include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h" | 19 #include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h" |
20 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i
sac.h" | 20 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i
sac.h" |
21 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" | 21 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" |
22 #include "webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h" | 22 #include "webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h" |
23 #include "webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h" | 23 #include "webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h" |
24 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" | 24 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
25 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef
s.h" | 25 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef
s.h" |
| 26 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" |
| 27 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" |
26 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h" | 28 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h" |
27 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
28 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" | 30 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" |
29 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" | 31 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" |
30 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" | 32 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" |
31 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" | 33 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" |
32 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" | 34 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
33 #include "webrtc/modules/interface/module_common_types.h" | 35 #include "webrtc/modules/interface/module_common_types.h" |
34 #include "webrtc/system_wrappers/interface/clock.h" | 36 #include "webrtc/system_wrappers/interface/clock.h" |
35 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 37 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 #if defined(_WIN32) && defined(WEBRTC_ARCH_64_BITS) | 868 #if defined(_WIN32) && defined(WEBRTC_ARCH_64_BITS) |
867 return win64; | 869 return win64; |
868 #elif defined(WEBRTC_ANDROID) | 870 #elif defined(WEBRTC_ANDROID) |
869 return android; | 871 return android; |
870 #else | 872 #else |
871 return others; | 873 return others; |
872 #endif | 874 #endif |
873 } | 875 } |
874 | 876 |
875 protected: | 877 protected: |
876 void Run(int output_freq_hz, const std::string& checksum_ref) { | 878 struct ExternalDecoder { |
| 879 int rtp_payload_type; |
| 880 AudioDecoder* external_decoder; |
| 881 int sample_rate_hz; |
| 882 int num_channels; |
| 883 }; |
| 884 |
| 885 void Run(int output_freq_hz, |
| 886 const std::string& checksum_ref, |
| 887 const std::vector<ExternalDecoder>& external_decoders) { |
877 const std::string input_file_name = | 888 const std::string input_file_name = |
878 webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); | 889 webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); |
879 rtc::scoped_ptr<test::RtpFileSource> packet_source( | 890 rtc::scoped_ptr<test::RtpFileSource> packet_source( |
880 test::RtpFileSource::Create(input_file_name)); | 891 test::RtpFileSource::Create(input_file_name)); |
881 #ifdef WEBRTC_ANDROID | 892 #ifdef WEBRTC_ANDROID |
882 // Filter out iLBC and iSAC-swb since they are not supported on Android. | 893 // Filter out iLBC and iSAC-swb since they are not supported on Android. |
883 packet_source->FilterOutPayloadType(102); // iLBC. | 894 packet_source->FilterOutPayloadType(102); // iLBC. |
884 packet_source->FilterOutPayloadType(104); // iSAC-swb. | 895 packet_source->FilterOutPayloadType(104); // iSAC-swb. |
885 #endif | 896 #endif |
886 | 897 |
887 test::AudioChecksum checksum; | 898 test::AudioChecksum checksum; |
888 const std::string output_file_name = | 899 const std::string output_file_name = |
889 webrtc::test::OutputPath() + | 900 webrtc::test::OutputPath() + |
890 ::testing::UnitTest::GetInstance() | 901 ::testing::UnitTest::GetInstance() |
891 ->current_test_info() | 902 ->current_test_info() |
892 ->test_case_name() + | 903 ->test_case_name() + |
893 "_" + ::testing::UnitTest::GetInstance()->current_test_info()->name() + | 904 "_" + ::testing::UnitTest::GetInstance()->current_test_info()->name() + |
894 "_output.pcm"; | 905 "_output.pcm"; |
895 test::OutputAudioFile output_file(output_file_name); | 906 test::OutputAudioFile output_file(output_file_name); |
896 test::AudioSinkFork output(&checksum, &output_file); | 907 test::AudioSinkFork output(&checksum, &output_file); |
897 | 908 |
898 test::AcmReceiveTestOldApi test( | 909 test::AcmReceiveTestOldApi test( |
899 packet_source.get(), | 910 packet_source.get(), |
900 &output, | 911 &output, |
901 output_freq_hz, | 912 output_freq_hz, |
902 test::AcmReceiveTestOldApi::kArbitraryChannels); | 913 test::AcmReceiveTestOldApi::kArbitraryChannels); |
903 ASSERT_NO_FATAL_FAILURE(test.RegisterNetEqTestCodecs()); | 914 ASSERT_NO_FATAL_FAILURE(test.RegisterNetEqTestCodecs()); |
| 915 for (const auto& ed : external_decoders) { |
| 916 ASSERT_EQ(0, test.RegisterExternalReceiveCodec( |
| 917 ed.rtp_payload_type, ed.external_decoder, |
| 918 ed.sample_rate_hz, ed.num_channels)); |
| 919 } |
904 test.Run(); | 920 test.Run(); |
905 | 921 |
906 std::string checksum_string = checksum.Finish(); | 922 std::string checksum_string = checksum.Finish(); |
907 EXPECT_EQ(checksum_ref, checksum_string); | 923 EXPECT_EQ(checksum_ref, checksum_string); |
908 } | 924 } |
909 }; | 925 }; |
910 | 926 |
911 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 | 927 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 |
912 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) | 928 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) |
913 #define MAYBE_8kHzOutput DISABLED_8kHzOutput | 929 #define MAYBE_8kHzOutput DISABLED_8kHzOutput |
914 #else | 930 #else |
915 #define MAYBE_8kHzOutput 8kHzOutput | 931 #define MAYBE_8kHzOutput 8kHzOutput |
916 #endif | 932 #endif |
917 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_8kHzOutput) { | 933 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_8kHzOutput) { |
918 Run(8000, | 934 Run(8000, PlatformChecksum("dcee98c623b147ebe1b40dd30efa896e", |
919 PlatformChecksum("dcee98c623b147ebe1b40dd30efa896e", | 935 "adc92e173f908f93b96ba5844209815a", |
920 "adc92e173f908f93b96ba5844209815a", | 936 "908002dc01fc4eb1d2be24eb1d3f354b"), |
921 "908002dc01fc4eb1d2be24eb1d3f354b")); | 937 std::vector<ExternalDecoder>()); |
922 } | 938 } |
923 | 939 |
924 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 | 940 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 |
925 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) | 941 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) |
926 #define MAYBE_16kHzOutput DISABLED_16kHzOutput | 942 #define MAYBE_16kHzOutput DISABLED_16kHzOutput |
927 #else | 943 #else |
928 #define MAYBE_16kHzOutput 16kHzOutput | 944 #define MAYBE_16kHzOutput 16kHzOutput |
929 #endif | 945 #endif |
930 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_16kHzOutput) { | 946 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_16kHzOutput) { |
931 Run(16000, | 947 Run(16000, PlatformChecksum("f790e7a8cce4e2c8b7bb5e0e4c5dac0d", |
932 PlatformChecksum("f790e7a8cce4e2c8b7bb5e0e4c5dac0d", | 948 "8cffa6abcb3e18e33b9d857666dff66a", |
933 "8cffa6abcb3e18e33b9d857666dff66a", | 949 "a909560b5ca49fa472b17b7b277195e9"), |
934 "a909560b5ca49fa472b17b7b277195e9")); | 950 std::vector<ExternalDecoder>()); |
935 } | 951 } |
936 | 952 |
937 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 | 953 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 |
938 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) | 954 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) |
939 #define MAYBE_32kHzOutput DISABLED_32kHzOutput | 955 #define MAYBE_32kHzOutput DISABLED_32kHzOutput |
940 #else | 956 #else |
941 #define MAYBE_32kHzOutput 32kHzOutput | 957 #define MAYBE_32kHzOutput 32kHzOutput |
942 #endif | 958 #endif |
943 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_32kHzOutput) { | 959 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_32kHzOutput) { |
944 Run(32000, | 960 Run(32000, PlatformChecksum("306e0d990ee6e92de3fbecc0123ece37", |
945 PlatformChecksum("306e0d990ee6e92de3fbecc0123ece37", | 961 "3e126fe894720c3f85edadcc91964ba5", |
946 "3e126fe894720c3f85edadcc91964ba5", | 962 "441aab4b347fb3db4e9244337aca8d8e"), |
947 "441aab4b347fb3db4e9244337aca8d8e")); | 963 std::vector<ExternalDecoder>()); |
948 } | 964 } |
949 | 965 |
950 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 | 966 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 |
951 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) | 967 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) |
952 #define MAYBE_48kHzOutput DISABLED_48kHzOutput | 968 #define MAYBE_48kHzOutput DISABLED_48kHzOutput |
953 #else | 969 #else |
954 #define MAYBE_48kHzOutput 48kHzOutput | 970 #define MAYBE_48kHzOutput 48kHzOutput |
955 #endif | 971 #endif |
956 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_48kHzOutput) { | 972 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_48kHzOutput) { |
957 Run(48000, | 973 Run(48000, PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0", |
958 PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0", | 974 "0155665e93067c4e89256b944dd11999", |
959 "0155665e93067c4e89256b944dd11999", | 975 "4ee2730fa1daae755e8a8fd3abd779ec"), |
960 "4ee2730fa1daae755e8a8fd3abd779ec")); | 976 std::vector<ExternalDecoder>()); |
| 977 } |
| 978 |
| 979 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199 |
| 980 #if defined(WEBRTC_ANDROID) && defined(__aarch64__) |
| 981 #define MAYBE_48kHzOutputExternalDecoder DISABLED_48kHzOutputExternalDecoder |
| 982 #else |
| 983 #define MAYBE_48kHzOutputExternalDecoder 48kHzOutputExternalDecoder |
| 984 #endif |
| 985 TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_48kHzOutputExternalDecoder) { |
| 986 AudioDecoderPcmU decoder; |
| 987 MockAudioDecoder mock_decoder; |
| 988 // Set expectations on the mock decoder and also delegate the calls to the |
| 989 // real decoder. |
| 990 EXPECT_CALL(mock_decoder, Init()) |
| 991 .Times(AtLeast(1)) |
| 992 .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::Init)); |
| 993 EXPECT_CALL(mock_decoder, IncomingPacket(_, _, _, _, _)) |
| 994 .Times(AtLeast(1)) |
| 995 .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::IncomingPacket)); |
| 996 EXPECT_CALL(mock_decoder, Channels()) |
| 997 .Times(AtLeast(1)) |
| 998 .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::Channels)); |
| 999 EXPECT_CALL(mock_decoder, Decode(_, _, _, _, _, _)) |
| 1000 .Times(AtLeast(1)) |
| 1001 .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::Decode)); |
| 1002 EXPECT_CALL(mock_decoder, HasDecodePlc()) |
| 1003 .Times(AtLeast(1)) |
| 1004 .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::HasDecodePlc)); |
| 1005 ExternalDecoder ed; |
| 1006 ed.rtp_payload_type = 0; |
| 1007 ed.external_decoder = &mock_decoder; |
| 1008 ed.sample_rate_hz = 8000; |
| 1009 ed.num_channels = 1; |
| 1010 std::vector<ExternalDecoder> external_decoders; |
| 1011 external_decoders.push_back(ed); |
| 1012 |
| 1013 Run(48000, PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0", |
| 1014 "0155665e93067c4e89256b944dd11999", |
| 1015 "4ee2730fa1daae755e8a8fd3abd779ec"), |
| 1016 external_decoders); |
| 1017 |
| 1018 EXPECT_CALL(mock_decoder, Die()); |
961 } | 1019 } |
962 | 1020 |
963 // This test verifies bit exactness for the send-side of ACM. The test setup is | 1021 // This test verifies bit exactness for the send-side of ACM. The test setup is |
964 // a chain of three different test classes: | 1022 // a chain of three different test classes: |
965 // | 1023 // |
966 // test::AcmSendTest -> AcmSenderBitExactness -> test::AcmReceiveTest | 1024 // test::AcmSendTest -> AcmSenderBitExactness -> test::AcmReceiveTest |
967 // | 1025 // |
968 // The receiver side is driving the test by requesting new packets from | 1026 // The receiver side is driving the test by requesting new packets from |
969 // AcmSenderBitExactness::NextPacket(). This method, in turn, asks for the | 1027 // AcmSenderBitExactness::NextPacket(). This method, in turn, asks for the |
970 // packet from test::AcmSendTest::NextPacket, which inserts audio from the | 1028 // packet from test::AcmSendTest::NextPacket, which inserts audio from the |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 Run(16000, 8000, 1000); | 1742 Run(16000, 8000, 1000); |
1685 } | 1743 } |
1686 | 1744 |
1687 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { | 1745 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { |
1688 Run(8000, 16000, 1000); | 1746 Run(8000, 16000, 1000); |
1689 } | 1747 } |
1690 | 1748 |
1691 #endif | 1749 #endif |
1692 | 1750 |
1693 } // namespace webrtc | 1751 } // namespace webrtc |
OLD | NEW |