Chromium Code Reviews| 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 // The best that can be done with PESQ. | 24 DEFINE_int32(sampling_frequency, 16000, |
|
kwiberg-webrtc
2017/04/12 07:13:49
As always, I'm going to suggest that you call this
oprypin_webrtc
2017/04/12 11:24:56
Done.
| |
| 24 constexpr int kAudioFileBitRate = 16000; | 25 "Sampling frequency (Hz) of the produced audio files."); |
|
kwiberg-webrtc
2017/04/12 07:13:49
Look it up before you take my advice because I'm n
oprypin_webrtc
2017/04/12 11:24:56
OK. Indeed, flags are usually put in the global na
| |
| 25 } // namespace | 26 } // namespace |
| 26 | 27 |
| 27 namespace webrtc { | 28 namespace webrtc { |
| 28 namespace test { | 29 namespace test { |
| 29 | 30 |
| 30 AudioQualityTest::AudioQualityTest() | 31 AudioQualityTest::AudioQualityTest() |
| 31 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} | 32 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} |
| 32 | 33 |
| 33 size_t AudioQualityTest::GetNumVideoStreams() const { | 34 size_t AudioQualityTest::GetNumVideoStreams() const { |
| 34 return 0; | 35 return 0; |
| 35 } | 36 } |
| 36 size_t AudioQualityTest::GetNumAudioStreams() const { | 37 size_t AudioQualityTest::GetNumAudioStreams() const { |
| 37 return 1; | 38 return 1; |
| 38 } | 39 } |
| 39 size_t AudioQualityTest::GetNumFlexfecStreams() const { | 40 size_t AudioQualityTest::GetNumFlexfecStreams() const { |
| 40 return 0; | 41 return 0; |
| 41 } | 42 } |
| 42 | 43 |
| 43 std::string AudioQualityTest::AudioInputFile() { | 44 std::string AudioQualityTest::AudioInputFile() { |
| 44 return test::ResourcePath("voice_engine/audio_tiny16", "wav"); | 45 return test::ResourcePath("voice_engine/audio_tiny" + |
| 46 std::to_string(FLAGS_sampling_frequency / 1000), | |
| 47 "wav"); | |
| 45 } | 48 } |
| 46 | 49 |
| 47 std::string AudioQualityTest::AudioOutputFile() { | 50 std::string AudioQualityTest::AudioOutputFile() { |
| 48 const ::testing::TestInfo* const test_info = | 51 const ::testing::TestInfo* const test_info = |
| 49 ::testing::UnitTest::GetInstance()->current_test_info(); | 52 ::testing::UnitTest::GetInstance()->current_test_info(); |
| 50 return webrtc::test::OutputPath() + | 53 return webrtc::test::OutputPath() + "LowBandwidth_" + test_info->name() + |
| 51 "LowBandwidth_" + test_info->name() + ".wav"; | 54 "_" + std::to_string(FLAGS_sampling_frequency / 1000) + ".wav"; |
|
kwiberg-webrtc
2017/04/12 07:13:49
You construct this name more than once. Utility fu
oprypin_webrtc
2017/04/12 11:24:56
Done.
| |
| 52 } | 55 } |
| 53 | 56 |
| 54 std::unique_ptr<test::FakeAudioDevice::Capturer> | 57 std::unique_ptr<test::FakeAudioDevice::Capturer> |
| 55 AudioQualityTest::CreateCapturer() { | 58 AudioQualityTest::CreateCapturer() { |
| 56 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); | 59 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); |
| 57 } | 60 } |
| 58 | 61 |
| 59 std::unique_ptr<test::FakeAudioDevice::Renderer> | 62 std::unique_ptr<test::FakeAudioDevice::Renderer> |
| 60 AudioQualityTest::CreateRenderer() { | 63 AudioQualityTest::CreateRenderer() { |
| 61 return test::FakeAudioDevice::CreateBoundedWavFileWriter( | 64 return test::FakeAudioDevice::CreateBoundedWavFileWriter( |
| 62 AudioOutputFile(), kAudioFileBitRate); | 65 AudioOutputFile(), FLAGS_sampling_frequency); |
| 63 } | 66 } |
| 64 | 67 |
| 65 void AudioQualityTest::OnFakeAudioDevicesCreated( | 68 void AudioQualityTest::OnFakeAudioDevicesCreated( |
| 66 test::FakeAudioDevice* send_audio_device, | 69 test::FakeAudioDevice* send_audio_device, |
| 67 test::FakeAudioDevice* recv_audio_device) { | 70 test::FakeAudioDevice* recv_audio_device) { |
| 68 send_audio_device_ = send_audio_device; | 71 send_audio_device_ = send_audio_device; |
| 69 } | 72 } |
| 70 | 73 |
| 71 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { | 74 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { |
| 72 return FakeNetworkPipe::Config(); | 75 return FakeNetworkPipe::Config(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 143 } |
| 141 }; | 144 }; |
| 142 | 145 |
| 143 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 146 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
| 144 Mobile2GNetworkTest test; | 147 Mobile2GNetworkTest test; |
| 145 RunBaseTest(&test); | 148 RunBaseTest(&test); |
| 146 } | 149 } |
| 147 | 150 |
| 148 } // namespace test | 151 } // namespace test |
| 149 } // namespace webrtc | 152 } // namespace webrtc |
| OLD | NEW |