OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 <algorithm> | 11 #include <algorithm> |
12 | 12 |
13 #include "gflags/gflags.h" | |
13 #include "webrtc/audio/test/low_bandwidth_audio_test.h" | 14 #include "webrtc/audio/test/low_bandwidth_audio_test.h" |
14 #include "webrtc/common_audio/wav_file.h" | 15 #include "webrtc/common_audio/wav_file.h" |
15 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
16 #include "webrtc/system_wrappers/include/sleep.h" | 17 #include "webrtc/system_wrappers/include/sleep.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 18 #include "webrtc/test/testsupport/fileutils.h" |
18 | 19 |
20 | |
21 DEFINE_int32(sample_rate_hz, 16000, | |
22 "Sample rate (Hz) of the produced audio files."); | |
23 | |
19 namespace { | 24 namespace { |
25 | |
20 // Wait half a second between stopping sending and stopping receiving audio. | 26 // Wait half a second between stopping sending and stopping receiving audio. |
21 constexpr int kExtraRecordTimeMs = 500; | 27 constexpr int kExtraRecordTimeMs = 500; |
22 | 28 |
23 // The best that can be done with PESQ. | 29 std::string FileSampleRateSuffix(int sample_rate_hz = FLAGS_sample_rate_hz) { |
kwiberg-webrtc
2017/04/12 11:35:06
You don't use the argument; remove it?
oprypin_webrtc
2017/04/12 11:42:32
Oops. Thanks.
| |
24 constexpr int kAudioFileBitRate = 16000; | 30 return std::to_string(FLAGS_sample_rate_hz / 1000); |
31 } | |
32 | |
25 } // namespace | 33 } // namespace |
26 | 34 |
27 namespace webrtc { | 35 namespace webrtc { |
28 namespace test { | 36 namespace test { |
29 | 37 |
30 AudioQualityTest::AudioQualityTest() | 38 AudioQualityTest::AudioQualityTest() |
31 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} | 39 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} |
32 | 40 |
33 size_t AudioQualityTest::GetNumVideoStreams() const { | 41 size_t AudioQualityTest::GetNumVideoStreams() const { |
34 return 0; | 42 return 0; |
35 } | 43 } |
36 size_t AudioQualityTest::GetNumAudioStreams() const { | 44 size_t AudioQualityTest::GetNumAudioStreams() const { |
37 return 1; | 45 return 1; |
38 } | 46 } |
39 size_t AudioQualityTest::GetNumFlexfecStreams() const { | 47 size_t AudioQualityTest::GetNumFlexfecStreams() const { |
40 return 0; | 48 return 0; |
41 } | 49 } |
42 | 50 |
43 std::string AudioQualityTest::AudioInputFile() { | 51 std::string AudioQualityTest::AudioInputFile() { |
44 return test::ResourcePath("voice_engine/audio_tiny16", "wav"); | 52 return test::ResourcePath("voice_engine/audio_tiny" + FileSampleRateSuffix(), |
53 "wav"); | |
45 } | 54 } |
46 | 55 |
47 std::string AudioQualityTest::AudioOutputFile() { | 56 std::string AudioQualityTest::AudioOutputFile() { |
48 const ::testing::TestInfo* const test_info = | 57 const ::testing::TestInfo* const test_info = |
49 ::testing::UnitTest::GetInstance()->current_test_info(); | 58 ::testing::UnitTest::GetInstance()->current_test_info(); |
50 return webrtc::test::OutputPath() + | 59 return webrtc::test::OutputPath() + "LowBandwidth_" + test_info->name() + |
51 "LowBandwidth_" + test_info->name() + ".wav"; | 60 "_" + FileSampleRateSuffix() + ".wav"; |
52 } | 61 } |
53 | 62 |
54 std::unique_ptr<test::FakeAudioDevice::Capturer> | 63 std::unique_ptr<test::FakeAudioDevice::Capturer> |
55 AudioQualityTest::CreateCapturer() { | 64 AudioQualityTest::CreateCapturer() { |
56 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); | 65 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); |
57 } | 66 } |
58 | 67 |
59 std::unique_ptr<test::FakeAudioDevice::Renderer> | 68 std::unique_ptr<test::FakeAudioDevice::Renderer> |
60 AudioQualityTest::CreateRenderer() { | 69 AudioQualityTest::CreateRenderer() { |
61 return test::FakeAudioDevice::CreateBoundedWavFileWriter( | 70 return test::FakeAudioDevice::CreateBoundedWavFileWriter( |
62 AudioOutputFile(), kAudioFileBitRate); | 71 AudioOutputFile(), FLAGS_sample_rate_hz); |
63 } | 72 } |
64 | 73 |
65 void AudioQualityTest::OnFakeAudioDevicesCreated( | 74 void AudioQualityTest::OnFakeAudioDevicesCreated( |
66 test::FakeAudioDevice* send_audio_device, | 75 test::FakeAudioDevice* send_audio_device, |
67 test::FakeAudioDevice* recv_audio_device) { | 76 test::FakeAudioDevice* recv_audio_device) { |
68 send_audio_device_ = send_audio_device; | 77 send_audio_device_ = send_audio_device; |
69 } | 78 } |
70 | 79 |
71 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { | 80 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { |
72 return FakeNetworkPipe::Config(); | 81 return FakeNetworkPipe::Config(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 } | 149 } |
141 }; | 150 }; |
142 | 151 |
143 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 152 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
144 Mobile2GNetworkTest test; | 153 Mobile2GNetworkTest test; |
145 RunBaseTest(&test); | 154 RunBaseTest(&test); |
146 } | 155 } |
147 | 156 |
148 } // namespace test | 157 } // namespace test |
149 } // namespace webrtc | 158 } // namespace webrtc |
OLD | NEW |