| 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 "gflags/gflags.h" |
| 14 #include "webrtc/audio/test/low_bandwidth_audio_test.h" | 14 #include "webrtc/audio/test/low_bandwidth_audio_test.h" |
| 15 #include "webrtc/common_audio/wav_file.h" | 15 #include "webrtc/common_audio/wav_file.h" |
| 16 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
| 17 #include "webrtc/system_wrappers/include/sleep.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_int32(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, |
| 25 "Don't do the full audio recording. " |
| 26 "Used to quickly check that the test runs without crashing."); |
| 27 |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 // Wait half a second between stopping sending and stopping receiving audio. | 30 // Wait half a second between stopping sending and stopping receiving audio. |
| 27 constexpr int kExtraRecordTimeMs = 500; | 31 constexpr int kExtraRecordTimeMs = 500; |
| 28 | 32 |
| 29 std::string FileSampleRateSuffix() { | 33 std::string FileSampleRateSuffix() { |
| 30 return std::to_string(FLAGS_sample_rate_hz / 1000); | 34 return std::to_string(FLAGS_sample_rate_hz / 1000); |
| 31 } | 35 } |
| 32 | 36 |
| 33 } // namespace | 37 } // namespace |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 std::vector<AudioReceiveStream::Config>* receive_configs) { | 103 std::vector<AudioReceiveStream::Config>* receive_configs) { |
| 100 // Large bitrate by default. | 104 // Large bitrate by default. |
| 101 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, | 105 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, |
| 102 {{"stereo", "1"}}); | 106 {{"stereo", "1"}}); |
| 103 send_config->send_codec_spec = | 107 send_config->send_codec_spec = |
| 104 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( | 108 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( |
| 105 {test::CallTest::kAudioSendPayloadType, kDefaultFormat}); | 109 {test::CallTest::kAudioSendPayloadType, kDefaultFormat}); |
| 106 } | 110 } |
| 107 | 111 |
| 108 void AudioQualityTest::PerformTest() { | 112 void AudioQualityTest::PerformTest() { |
| 109 // Wait until the input audio file is done... | 113 if (FLAGS_quick) { |
| 110 send_audio_device_->WaitForRecordingEnd(); | 114 // Let the recording run for a small amount of time to check if it works. |
| 111 // and some extra time to account for network delay. | 115 SleepMs(1000); |
| 112 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); | 116 } else { |
| 117 // Wait until the input audio file is done... |
| 118 send_audio_device_->WaitForRecordingEnd(); |
| 119 // and some extra time to account for network delay. |
| 120 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); |
| 121 } |
| 113 } | 122 } |
| 114 | 123 |
| 115 void AudioQualityTest::OnTestFinished() { | 124 void AudioQualityTest::OnTestFinished() { |
| 116 const ::testing::TestInfo* const test_info = | 125 const ::testing::TestInfo* const test_info = |
| 117 ::testing::UnitTest::GetInstance()->current_test_info(); | 126 ::testing::UnitTest::GetInstance()->current_test_info(); |
| 118 | 127 |
| 119 // Output information about the input and output audio files so that further | 128 // Output information about the input and output audio files so that further |
| 120 // processing can be done by an external process. | 129 // processing can be done by an external process. |
| 121 printf("TEST %s %s %s\n", test_info->name(), | 130 printf("TEST %s %s %s\n", test_info->name(), |
| 122 AudioInputFile().c_str(), AudioOutputFile().c_str()); | 131 AudioInputFile().c_str(), AudioOutputFile().c_str()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 163 } |
| 155 }; | 164 }; |
| 156 | 165 |
| 157 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 166 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
| 158 Mobile2GNetworkTest test; | 167 Mobile2GNetworkTest test; |
| 159 RunBaseTest(&test); | 168 RunBaseTest(&test); |
| 160 } | 169 } |
| 161 | 170 |
| 162 } // namespace test | 171 } // namespace test |
| 163 } // namespace webrtc | 172 } // namespace webrtc |
| OLD | NEW |