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 "webrtc/audio/test/low_bandwidth_audio_test.h" | 13 #include "webrtc/audio/test/low_bandwidth_audio_test.h" |
14 #include "webrtc/common_audio/wav_file.h" | 14 #include "webrtc/common_audio/wav_file.h" |
15 #include "webrtc/test/gtest.h" | 15 #include "webrtc/test/gtest.h" |
16 #include "webrtc/system_wrappers/include/sleep.h" | 16 #include "webrtc/system_wrappers/include/sleep.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 17 #include "webrtc/test/testsupport/fileutils.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 // Wait half a second between stopping sending and stopping receiving audio. | 20 // Wait half a second between stopping sending and stopping receiving audio. |
21 constexpr int kExtraRecordTimeMs = 500; | 21 constexpr int kExtraRecordTimeMs = 500; |
22 | 22 |
23 // Large bitrate by default. | |
24 const webrtc::CodecInst kDefaultCodec{120, "OPUS", 48000, 960, 2, 64000}; | |
25 | |
26 // The best that can be done with PESQ. | 23 // The best that can be done with PESQ. |
27 constexpr int kAudioFileBitRate = 16000; | 24 constexpr int kAudioFileBitRate = 16000; |
28 } | 25 } |
29 | 26 |
30 namespace webrtc { | 27 namespace webrtc { |
31 namespace test { | 28 namespace test { |
32 | 29 |
33 AudioQualityTest::AudioQualityTest() | 30 AudioQualityTest::AudioQualityTest() |
34 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} | 31 : EndToEndTest(CallTest::kDefaultTimeoutMs) {} |
35 | 32 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 82 |
86 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() { | 83 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() { |
87 return new test::PacketTransport(nullptr, this, | 84 return new test::PacketTransport(nullptr, this, |
88 test::PacketTransport::kReceiver, MediaType::AUDIO, | 85 test::PacketTransport::kReceiver, MediaType::AUDIO, |
89 GetNetworkPipeConfig()); | 86 GetNetworkPipeConfig()); |
90 } | 87 } |
91 | 88 |
92 void AudioQualityTest::ModifyAudioConfigs( | 89 void AudioQualityTest::ModifyAudioConfigs( |
93 AudioSendStream::Config* send_config, | 90 AudioSendStream::Config* send_config, |
94 std::vector<AudioReceiveStream::Config>* receive_configs) { | 91 std::vector<AudioReceiveStream::Config>* receive_configs) { |
95 send_config->send_codec_spec.codec_inst = kDefaultCodec; | 92 // Large bitrate by default. |
| 93 const webrtc::SdpAudioFormat kDefaultFormat("OPUS", 48000, 2, |
| 94 {{"stereo", "1"}}); |
| 95 send_config->send_codec_spec = |
| 96 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( |
| 97 {120, kDefaultFormat}); |
96 } | 98 } |
97 | 99 |
98 void AudioQualityTest::PerformTest() { | 100 void AudioQualityTest::PerformTest() { |
99 // Wait until the input audio file is done... | 101 // Wait until the input audio file is done... |
100 send_audio_device_->WaitForRecordingEnd(); | 102 send_audio_device_->WaitForRecordingEnd(); |
101 // and some extra time to account for network delay. | 103 // and some extra time to account for network delay. |
102 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); | 104 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); |
103 } | 105 } |
104 | 106 |
105 void AudioQualityTest::OnTestFinished() { | 107 void AudioQualityTest::OnTestFinished() { |
(...skipping 11 matching lines...) Expand all Loading... |
117 | 119 |
118 TEST_F(LowBandwidthAudioTest, GoodNetworkHighBitrate) { | 120 TEST_F(LowBandwidthAudioTest, GoodNetworkHighBitrate) { |
119 AudioQualityTest test; | 121 AudioQualityTest test; |
120 RunBaseTest(&test); | 122 RunBaseTest(&test); |
121 } | 123 } |
122 | 124 |
123 | 125 |
124 class Mobile2GNetworkTest : public AudioQualityTest { | 126 class Mobile2GNetworkTest : public AudioQualityTest { |
125 void ModifyAudioConfigs(AudioSendStream::Config* send_config, | 127 void ModifyAudioConfigs(AudioSendStream::Config* send_config, |
126 std::vector<AudioReceiveStream::Config>* receive_configs) override { | 128 std::vector<AudioReceiveStream::Config>* receive_configs) override { |
127 send_config->send_codec_spec.codec_inst = CodecInst{ | 129 send_config->send_codec_spec = |
128 120, // pltype | 130 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( |
129 "OPUS", // plname | 131 {120, |
130 48000, // plfreq | 132 {"OPUS", |
131 2880, // pacsize | 133 48000, |
132 1, // channels | 134 2, |
133 6000 // rate bits/sec | 135 {{"maxaveragebitrate", "6000"}, |
134 }; | 136 {"ptime", "60"}, |
| 137 {"stereo", "1"}}}}); |
135 } | 138 } |
136 | 139 |
137 FakeNetworkPipe::Config GetNetworkPipeConfig() override { | 140 FakeNetworkPipe::Config GetNetworkPipeConfig() override { |
138 FakeNetworkPipe::Config pipe_config; | 141 FakeNetworkPipe::Config pipe_config; |
139 pipe_config.link_capacity_kbps = 12; | 142 pipe_config.link_capacity_kbps = 12; |
140 pipe_config.queue_length_packets = 1500; | 143 pipe_config.queue_length_packets = 1500; |
141 pipe_config.queue_delay_ms = 400; | 144 pipe_config.queue_delay_ms = 400; |
142 return pipe_config; | 145 return pipe_config; |
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 |