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 "gflags/gflags.h" |
| 14 | |
| 14 #include "webrtc/audio/test/low_bandwidth_audio_test.h" | 15 #include "webrtc/audio/test/low_bandwidth_audio_test.h" |
| 16 #include "webrtc/base/ptr_util.h" | |
| 15 #include "webrtc/common_audio/wav_file.h" | 17 #include "webrtc/common_audio/wav_file.h" |
| 18 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" | |
| 19 #include "webrtc/system_wrappers/include/sleep.h" | |
| 20 #include "webrtc/test/field_trial.h" | |
| 21 #include "webrtc/test/gmock.h" | |
| 16 #include "webrtc/test/gtest.h" | 22 #include "webrtc/test/gtest.h" |
| 17 #include "webrtc/system_wrappers/include/sleep.h" | |
| 18 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
| 19 | 24 |
| 25 using ::testing::NiceMock; | |
| 26 using ::testing::Invoke; | |
| 27 using ::testing::_; | |
| 20 | 28 |
| 21 DEFINE_int32(sample_rate_hz, 16000, | 29 DEFINE_int32(sample_rate_hz, 16000, |
| 22 "Sample rate (Hz) of the produced audio files."); | 30 "Sample rate (Hz) of the produced audio files."); |
| 23 | 31 |
| 24 DEFINE_bool(quick, false, | 32 DEFINE_bool(quick, false, |
| 25 "Don't do the full audio recording. " | 33 "Don't do the full audio recording. " |
| 26 "Used to quickly check that the test runs without crashing."); | 34 "Used to quickly check that the test runs without crashing."); |
| 27 | 35 |
| 28 namespace { | 36 namespace { |
| 29 | |
| 30 // Wait half a second between stopping sending and stopping receiving audio. | 37 // Wait half a second between stopping sending and stopping receiving audio. |
| 31 constexpr int kExtraRecordTimeMs = 500; | 38 constexpr int kExtraRecordTimeMs = 500; |
| 32 | 39 |
| 33 std::string FileSampleRateSuffix() { | 40 std::string FileSampleRateSuffix() { |
| 34 return std::to_string(FLAGS_sample_rate_hz / 1000); | 41 return std::to_string(FLAGS_sample_rate_hz / 1000); |
| 35 } | 42 } |
| 36 | 43 |
| 37 } // namespace | 44 } // namespace |
| 38 | 45 |
| 39 namespace webrtc { | 46 namespace webrtc { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 test::FakeAudioDevice* recv_audio_device) { | 87 test::FakeAudioDevice* recv_audio_device) { |
| 81 send_audio_device_ = send_audio_device; | 88 send_audio_device_ = send_audio_device; |
| 82 } | 89 } |
| 83 | 90 |
| 84 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { | 91 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { |
| 85 return FakeNetworkPipe::Config(); | 92 return FakeNetworkPipe::Config(); |
| 86 } | 93 } |
| 87 | 94 |
| 88 test::PacketTransport* AudioQualityTest::CreateSendTransport( | 95 test::PacketTransport* AudioQualityTest::CreateSendTransport( |
| 89 Call* sender_call) { | 96 Call* sender_call) { |
| 97 sender_call_ = sender_call; | |
| 90 return new test::PacketTransport( | 98 return new test::PacketTransport( |
| 91 sender_call, this, test::PacketTransport::kSender, | 99 sender_call, this, test::PacketTransport::kSender, |
| 92 test::CallTest::payload_type_map_, GetNetworkPipeConfig()); | 100 test::CallTest::payload_type_map_, GetNetworkPipeConfig()); |
| 93 } | 101 } |
| 94 | 102 |
| 95 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() { | 103 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() { |
| 96 return new test::PacketTransport( | 104 return new test::PacketTransport( |
| 97 nullptr, this, test::PacketTransport::kReceiver, | 105 nullptr, this, test::PacketTransport::kReceiver, |
| 98 test::CallTest::payload_type_map_, GetNetworkPipeConfig()); | 106 test::CallTest::payload_type_map_, GetNetworkPipeConfig()); |
| 99 } | 107 } |
| 100 | 108 |
| 101 void AudioQualityTest::ModifyAudioConfigs( | 109 void AudioQualityTest::ModifyAudioConfigs( |
| 102 AudioSendStream::Config* send_config, | 110 AudioSendStream::Config* send_config, |
| 103 std::vector<AudioReceiveStream::Config>* receive_configs) { | 111 std::vector<AudioReceiveStream::Config>* receive_configs) { |
| 104 // Large bitrate by default. | 112 // Large bitrate by default. |
| 105 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, | 113 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, |
| 106 {{"stereo", "1"}}); | 114 {{"stereo", "1"}}); |
| 107 send_config->send_codec_spec = | 115 send_config->send_codec_spec = |
| 108 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( | 116 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( |
| 109 {test::CallTest::kAudioSendPayloadType, kDefaultFormat}); | 117 {test::CallTest::kAudioSendPayloadType, kDefaultFormat}); |
| 110 } | 118 } |
| 111 | 119 |
| 112 void AudioQualityTest::PerformTest() { | 120 void AudioQualityTest::PerformTest() { |
| 121 sender_call_->OnTransportOverheadChanged(webrtc::MediaType::AUDIO, 0); | |
| 122 | |
| 113 if (FLAGS_quick) { | 123 if (FLAGS_quick) { |
| 114 // Let the recording run for a small amount of time to check if it works. | 124 // Let the recording run for a small amount of time to check if it works. |
| 115 SleepMs(1000); | 125 SleepMs(1000); |
| 116 } else { | 126 } else { |
| 117 // Wait until the input audio file is done... | 127 // Wait until the input audio file is done... |
| 118 send_audio_device_->WaitForRecordingEnd(); | 128 send_audio_device_->WaitForRecordingEnd(); |
| 119 // and some extra time to account for network delay. | 129 // and some extra time to account for network delay. |
| 120 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); | 130 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); |
| 121 } | 131 } |
| 122 } | 132 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 pipe_config.queue_delay_ms = 400; | 171 pipe_config.queue_delay_ms = 400; |
| 162 return pipe_config; | 172 return pipe_config; |
| 163 } | 173 } |
| 164 }; | 174 }; |
| 165 | 175 |
| 166 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 176 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
| 167 Mobile2GNetworkTest test; | 177 Mobile2GNetworkTest test; |
| 168 RunBaseTest(&test); | 178 RunBaseTest(&test); |
| 169 } | 179 } |
| 170 | 180 |
| 181 class NoBandwidthDropAfterDTX : public AudioQualityTest { | |
| 182 void ModifyAudioConfigs( | |
| 183 AudioSendStream::Config* send_config, | |
| 184 std::vector<AudioReceiveStream::Config>* receive_configs) override { | |
| 185 send_config->send_codec_spec = | |
| 186 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( | |
| 187 {test::CallTest::kAudioSendPayloadType, | |
| 188 {"OPUS", | |
| 189 48000, | |
| 190 2, | |
| 191 {{"ptime", "60"}, {"usedtx", "1"}, {"stereo", "1"}}}}); | |
| 192 | |
| 193 send_config->min_bitrate_bps = 6000; | |
| 194 send_config->max_bitrate_bps = 100000; | |
| 195 send_config->rtp.extensions.push_back( | |
| 196 RtpExtension(RtpExtension::kTransportSequenceNumberUri, | |
| 197 kTransportSequenceNumberExtensionId)); | |
| 198 for (AudioReceiveStream::Config& recv_config : *receive_configs) { | |
| 199 recv_config.rtp.transport_cc = true; | |
| 200 recv_config.rtp.extensions = send_config->rtp.extensions; | |
| 201 recv_config.rtp.remote_ssrc = send_config->rtp.ssrc; | |
| 202 } | |
| 203 } | |
| 204 | |
| 205 std::string AudioInputFile() override { | |
| 206 return test::ResourcePath("voice_engine/audio_dtx16", "wav"); | |
| 207 } | |
| 208 | |
| 209 void LogDelayBasedBweUpdate(int32_t bitrate_bps, | |
|
philipel
2017/06/14 09:34:05
Remove if not used.
tschumi
2017/06/14 10:57:46
Oops, this should not be like that.
| |
| 210 BandwidthUsage detector_state) { | |
| 211 EXPECT_GE(bitrate_bps, 30000); | |
| 212 } | |
| 213 | |
| 214 Call::Config GetSenderCallConfig() override { | |
| 215 event_log_ = std::unique_ptr<RtcEventLog>(RtcEventLog::Create()); | |
| 216 event_log_->StartLogging("dtx_test_event_log.dat"); | |
| 217 | |
| 218 // EXPECT_CALL(mock_event_log_, LogDelayBasedBweUpdate(_, _)) | |
|
philipel
2017/06/14 09:34:05
Remove commented code.
tschumi
2017/06/14 10:57:46
Oops, this should not be like that.
| |
| 219 // .WillRepeatedly(Invoke(this, &DTXTest::LogDelayBasedBweUpdate)); | |
| 220 | |
| 221 // Call::Config call_config(&mock_event_log_); | |
| 222 Call::Config call_config(event_log_.get()); | |
| 223 | |
| 224 return call_config; | |
| 225 } | |
| 226 | |
| 227 FakeNetworkPipe::Config GetNetworkPipeConfig() override { | |
| 228 FakeNetworkPipe::Config pipe_config; | |
| 229 pipe_config.link_capacity_kbps = 50; | |
| 230 pipe_config.queue_length_packets = 1500; | |
| 231 pipe_config.queue_delay_ms = 300; | |
| 232 return pipe_config; | |
| 233 } | |
| 234 | |
| 235 private: | |
| 236 NiceMock<MockRtcEventLog> mock_event_log_; | |
| 237 std::unique_ptr<RtcEventLog> event_log_; | |
| 238 }; | |
| 239 | |
| 240 TEST_F(LowBandwidthAudioTest, NoBandwidthDropAfterDTX) { | |
| 241 webrtc::test::ScopedFieldTrials override_field_trials( | |
| 242 "WebRTC-Audio-SendSideBwe/Enabled/" | |
| 243 "WebRTC-SendSideBwe-WithOverhead/Enabled/"); | |
| 244 NoBandwidthDropAfterDTX test; | |
| 245 RunBaseTest(&test); | |
| 246 } | |
| 247 | |
| 171 } // namespace test | 248 } // namespace test |
| 172 } // namespace webrtc | 249 } // namespace webrtc |
| OLD | NEW |