| 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" | |
| 14 #include "webrtc/audio/test/low_bandwidth_audio_test.h" | 13 #include "webrtc/audio/test/low_bandwidth_audio_test.h" |
| 15 #include "webrtc/common_audio/wav_file.h" | 14 #include "webrtc/common_audio/wav_file.h" |
| 15 #include "webrtc/rtc_base/flags.h" |
| 16 #include "webrtc/system_wrappers/include/sleep.h" |
| 16 #include "webrtc/test/gtest.h" | 17 #include "webrtc/test/gtest.h" |
| 17 #include "webrtc/system_wrappers/include/sleep.h" | |
| 18 #include "webrtc/test/testsupport/fileutils.h" | 18 #include "webrtc/test/testsupport/fileutils.h" |
| 19 | 19 |
| 20 | 20 |
| 21 DEFINE_int32(sample_rate_hz, 16000, | 21 DEFINE_int(sample_rate_hz, 16000, |
| 22 "Sample rate (Hz) of the produced audio files."); | 22 "Sample rate (Hz) of the produced audio files."); |
| 23 | 23 |
| 24 DEFINE_bool(quick, false, | 24 DEFINE_bool(quick, false, |
| 25 "Don't do the full audio recording. " | 25 "Don't do the full audio recording. " |
| 26 "Used to quickly check that the test runs without crashing."); | 26 "Used to quickly check that the test runs without crashing."); |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Wait half a second between stopping sending and stopping receiving audio. | 30 // Wait half a second between stopping sending and stopping receiving audio. |
| 31 constexpr int kExtraRecordTimeMs = 500; | 31 constexpr int kExtraRecordTimeMs = 500; |
| 32 | 32 |
| 33 std::string FileSampleRateSuffix() { | 33 std::string FileSampleRateSuffix() { |
| 34 return std::to_string(FLAGS_sample_rate_hz / 1000); | 34 return std::to_string(FLAG_sample_rate_hz / 1000); |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 namespace webrtc { | 39 namespace webrtc { |
| 40 namespace test { | 40 namespace test { |
| 41 | 41 |
| 42 AudioQualityTest::AudioQualityTest() | 42 AudioQualityTest::AudioQualityTest() |
| 43 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} | 43 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} |
| 44 | 44 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 std::unique_ptr<test::FakeAudioDevice::Capturer> | 67 std::unique_ptr<test::FakeAudioDevice::Capturer> |
| 68 AudioQualityTest::CreateCapturer() { | 68 AudioQualityTest::CreateCapturer() { |
| 69 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); | 69 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 std::unique_ptr<test::FakeAudioDevice::Renderer> | 72 std::unique_ptr<test::FakeAudioDevice::Renderer> |
| 73 AudioQualityTest::CreateRenderer() { | 73 AudioQualityTest::CreateRenderer() { |
| 74 return test::FakeAudioDevice::CreateBoundedWavFileWriter( | 74 return test::FakeAudioDevice::CreateBoundedWavFileWriter( |
| 75 AudioOutputFile(), FLAGS_sample_rate_hz); | 75 AudioOutputFile(), FLAG_sample_rate_hz); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void AudioQualityTest::OnFakeAudioDevicesCreated( | 78 void AudioQualityTest::OnFakeAudioDevicesCreated( |
| 79 test::FakeAudioDevice* send_audio_device, | 79 test::FakeAudioDevice* send_audio_device, |
| 80 test::FakeAudioDevice* recv_audio_device) { | 80 test::FakeAudioDevice* recv_audio_device) { |
| 81 send_audio_device_ = send_audio_device; | 81 send_audio_device_ = send_audio_device; |
| 82 } | 82 } |
| 83 | 83 |
| 84 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { | 84 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { |
| 85 return FakeNetworkPipe::Config(); | 85 return FakeNetworkPipe::Config(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 105 std::vector<AudioReceiveStream::Config>* receive_configs) { | 105 std::vector<AudioReceiveStream::Config>* receive_configs) { |
| 106 // Large bitrate by default. | 106 // Large bitrate by default. |
| 107 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, | 107 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, |
| 108 {{"stereo", "1"}}); | 108 {{"stereo", "1"}}); |
| 109 send_config->send_codec_spec = | 109 send_config->send_codec_spec = |
| 110 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( | 110 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( |
| 111 {test::CallTest::kAudioSendPayloadType, kDefaultFormat}); | 111 {test::CallTest::kAudioSendPayloadType, kDefaultFormat}); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void AudioQualityTest::PerformTest() { | 114 void AudioQualityTest::PerformTest() { |
| 115 if (FLAGS_quick) { | 115 if (FLAG_quick) { |
| 116 // Let the recording run for a small amount of time to check if it works. | 116 // Let the recording run for a small amount of time to check if it works. |
| 117 SleepMs(1000); | 117 SleepMs(1000); |
| 118 } else { | 118 } else { |
| 119 // Wait until the input audio file is done... | 119 // Wait until the input audio file is done... |
| 120 send_audio_device_->WaitForRecordingEnd(); | 120 send_audio_device_->WaitForRecordingEnd(); |
| 121 // and some extra time to account for network delay. | 121 // and some extra time to account for network delay. |
| 122 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); | 122 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 168 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
| 169 Mobile2GNetworkTest test; | 169 Mobile2GNetworkTest test; |
| 170 RunBaseTest(&test); | 170 RunBaseTest(&test); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace test | 173 } // namespace test |
| 174 } // namespace webrtc | 174 } // namespace webrtc |
| OLD | NEW |