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 |
19 namespace { | 20 namespace { |
20 // Wait half a second between stopping sending and stopping receiving audio. | 21 // Wait half a second between stopping sending and stopping receiving audio. |
21 constexpr int kExtraRecordTimeMs = 500; | 22 constexpr int kExtraRecordTimeMs = 500; |
22 | 23 |
23 // Large bitrate by default. | 24 // Large bitrate by default. |
24 const webrtc::CodecInst kDefaultCodec{120, "OPUS", 48000, 960, 2, 64000}; | 25 const webrtc::CodecInst kDefaultCodec{120, "OPUS", 48000, 960, 2, 64000}; |
25 | 26 |
26 // The best that can be done with PESQ. | 27 DEFINE_int32(sampling_frequency, 16000, |
27 constexpr int kAudioFileBitRate = 16000; | 28 "Sampling frequency (Hz) of the produced audio files."); |
28 } | 29 } |
29 | 30 |
30 namespace webrtc { | 31 namespace webrtc { |
31 namespace test { | 32 namespace test { |
32 | 33 |
33 AudioQualityTest::AudioQualityTest() | 34 AudioQualityTest::AudioQualityTest() |
34 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} | 35 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} |
35 | 36 |
36 size_t AudioQualityTest::GetNumVideoStreams() const { | 37 size_t AudioQualityTest::GetNumVideoStreams() const { |
37 return 0; | 38 return 0; |
38 } | 39 } |
39 size_t AudioQualityTest::GetNumAudioStreams() const { | 40 size_t AudioQualityTest::GetNumAudioStreams() const { |
40 return 1; | 41 return 1; |
41 } | 42 } |
42 size_t AudioQualityTest::GetNumFlexfecStreams() const { | 43 size_t AudioQualityTest::GetNumFlexfecStreams() const { |
43 return 0; | 44 return 0; |
44 } | 45 } |
45 | 46 |
46 std::string AudioQualityTest::AudioInputFile() { | 47 std::string AudioQualityTest::AudioInputFile() { |
47 return test::ResourcePath("voice_engine/audio_tiny16", "wav"); | 48 return test::ResourcePath("voice_engine/audio_tiny" + |
| 49 std::to_string(FLAGS_sampling_frequency / 1000), |
| 50 "wav"); |
48 } | 51 } |
49 | 52 |
50 std::string AudioQualityTest::AudioOutputFile() { | 53 std::string AudioQualityTest::AudioOutputFile() { |
51 const ::testing::TestInfo* const test_info = | 54 const ::testing::TestInfo* const test_info = |
52 ::testing::UnitTest::GetInstance()->current_test_info(); | 55 ::testing::UnitTest::GetInstance()->current_test_info(); |
53 return webrtc::test::OutputPath() + | 56 return webrtc::test::OutputPath() + "LowBandwidth_" + test_info->name() + |
54 "LowBandwidth_" + test_info->name() + ".wav"; | 57 "_" + std::to_string(FLAGS_sampling_frequency / 1000) + ".wav"; |
55 } | 58 } |
56 | 59 |
57 std::unique_ptr<test::FakeAudioDevice::Capturer> | 60 std::unique_ptr<test::FakeAudioDevice::Capturer> |
58 AudioQualityTest::CreateCapturer() { | 61 AudioQualityTest::CreateCapturer() { |
59 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); | 62 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); |
60 } | 63 } |
61 | 64 |
62 std::unique_ptr<test::FakeAudioDevice::Renderer> | 65 std::unique_ptr<test::FakeAudioDevice::Renderer> |
63 AudioQualityTest::CreateRenderer() { | 66 AudioQualityTest::CreateRenderer() { |
64 return test::FakeAudioDevice::CreateBoundedWavFileWriter( | 67 return test::FakeAudioDevice::CreateBoundedWavFileWriter( |
65 AudioOutputFile(), kAudioFileBitRate); | 68 AudioOutputFile(), FLAGS_sampling_frequency); |
66 } | 69 } |
67 | 70 |
68 void AudioQualityTest::OnFakeAudioDevicesCreated( | 71 void AudioQualityTest::OnFakeAudioDevicesCreated( |
69 test::FakeAudioDevice* send_audio_device, | 72 test::FakeAudioDevice* send_audio_device, |
70 test::FakeAudioDevice* recv_audio_device) { | 73 test::FakeAudioDevice* recv_audio_device) { |
71 send_audio_device_ = send_audio_device; | 74 send_audio_device_ = send_audio_device; |
72 } | 75 } |
73 | 76 |
74 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { | 77 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { |
75 return FakeNetworkPipe::Config(); | 78 return FakeNetworkPipe::Config(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 146 } |
144 }; | 147 }; |
145 | 148 |
146 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 149 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
147 Mobile2GNetworkTest test; | 150 Mobile2GNetworkTest test; |
148 RunBaseTest(&test); | 151 RunBaseTest(&test); |
149 } | 152 } |
150 | 153 |
151 } // namespace test | 154 } // namespace test |
152 } // namespace webrtc | 155 } // namespace webrtc |
OLD | NEW |