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 | |
oprypin_webrtc
2017/04/06 11:45:32
Why does the constant need to be moved?
minyue-webrtc
2017/04/06 11:56:33
Because I do not want to use "120" any longer. (Bu
| |
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 } // namespace |
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 |
36 size_t AudioQualityTest::GetNumVideoStreams() const { | 33 size_t AudioQualityTest::GetNumVideoStreams() const { |
37 return 0; | 34 return 0; |
38 } | 35 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 } | 69 } |
73 | 70 |
74 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { | 71 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() { |
75 return FakeNetworkPipe::Config(); | 72 return FakeNetworkPipe::Config(); |
76 } | 73 } |
77 | 74 |
78 test::PacketTransport* AudioQualityTest::CreateSendTransport( | 75 test::PacketTransport* AudioQualityTest::CreateSendTransport( |
79 Call* sender_call) { | 76 Call* sender_call) { |
80 return new test::PacketTransport( | 77 return new test::PacketTransport( |
81 sender_call, this, test::PacketTransport::kSender, | 78 sender_call, this, test::PacketTransport::kSender, |
82 MediaType::AUDIO, | 79 test::CallTest::payload_type_map_, GetNetworkPipeConfig()); |
83 GetNetworkPipeConfig()); | |
84 } | 80 } |
85 | 81 |
86 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() { | 82 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() { |
87 return new test::PacketTransport(nullptr, this, | 83 return new test::PacketTransport( |
88 test::PacketTransport::kReceiver, MediaType::AUDIO, | 84 nullptr, this, test::PacketTransport::kReceiver, |
89 GetNetworkPipeConfig()); | 85 test::CallTest::payload_type_map_, GetNetworkPipeConfig()); |
90 } | 86 } |
91 | 87 |
92 void AudioQualityTest::ModifyAudioConfigs( | 88 void AudioQualityTest::ModifyAudioConfigs( |
93 AudioSendStream::Config* send_config, | 89 AudioSendStream::Config* send_config, |
94 std::vector<AudioReceiveStream::Config>* receive_configs) { | 90 std::vector<AudioReceiveStream::Config>* receive_configs) { |
95 send_config->send_codec_spec.codec_inst = kDefaultCodec; | 91 send_config->send_codec_spec.codec_inst = webrtc::CodecInst{ |
92 test::CallTest::kAudioSendPayloadType, "OPUS", 48000, 960, 2, 64000}; | |
minyue-webrtc
2017/04/06 11:33:38
use the payload defined in CallTest so that Create
| |
96 } | 93 } |
97 | 94 |
98 void AudioQualityTest::PerformTest() { | 95 void AudioQualityTest::PerformTest() { |
99 // Wait until the input audio file is done... | 96 // Wait until the input audio file is done... |
100 send_audio_device_->WaitForRecordingEnd(); | 97 send_audio_device_->WaitForRecordingEnd(); |
101 // and some extra time to account for network delay. | 98 // and some extra time to account for network delay. |
102 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); | 99 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs); |
103 } | 100 } |
104 | 101 |
105 void AudioQualityTest::OnTestFinished() { | 102 void AudioQualityTest::OnTestFinished() { |
(...skipping 12 matching lines...) Expand all Loading... | |
118 TEST_F(LowBandwidthAudioTest, GoodNetworkHighBitrate) { | 115 TEST_F(LowBandwidthAudioTest, GoodNetworkHighBitrate) { |
119 AudioQualityTest test; | 116 AudioQualityTest test; |
120 RunBaseTest(&test); | 117 RunBaseTest(&test); |
121 } | 118 } |
122 | 119 |
123 | 120 |
124 class Mobile2GNetworkTest : public AudioQualityTest { | 121 class Mobile2GNetworkTest : public AudioQualityTest { |
125 void ModifyAudioConfigs(AudioSendStream::Config* send_config, | 122 void ModifyAudioConfigs(AudioSendStream::Config* send_config, |
126 std::vector<AudioReceiveStream::Config>* receive_configs) override { | 123 std::vector<AudioReceiveStream::Config>* receive_configs) override { |
127 send_config->send_codec_spec.codec_inst = CodecInst{ | 124 send_config->send_codec_spec.codec_inst = CodecInst{ |
128 120, // pltype | 125 test::CallTest::kAudioSendPayloadType, // pltype |
129 "OPUS", // plname | 126 "OPUS", // plname |
130 48000, // plfreq | 127 48000, // plfreq |
131 2880, // pacsize | 128 2880, // pacsize |
132 1, // channels | 129 1, // channels |
133 6000 // rate bits/sec | 130 6000 // rate bits/sec |
134 }; | 131 }; |
135 } | 132 } |
136 | 133 |
137 FakeNetworkPipe::Config GetNetworkPipeConfig() override { | 134 FakeNetworkPipe::Config GetNetworkPipeConfig() override { |
138 FakeNetworkPipe::Config pipe_config; | 135 FakeNetworkPipe::Config pipe_config; |
139 pipe_config.link_capacity_kbps = 12; | 136 pipe_config.link_capacity_kbps = 12; |
140 pipe_config.queue_length_packets = 1500; | 137 pipe_config.queue_length_packets = 1500; |
141 pipe_config.queue_delay_ms = 400; | 138 pipe_config.queue_delay_ms = 400; |
142 return pipe_config; | 139 return pipe_config; |
143 } | 140 } |
144 }; | 141 }; |
145 | 142 |
146 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { | 143 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) { |
147 Mobile2GNetworkTest test; | 144 Mobile2GNetworkTest test; |
148 RunBaseTest(&test); | 145 RunBaseTest(&test); |
149 } | 146 } |
150 | 147 |
151 } // namespace test | 148 } // namespace test |
152 } // namespace webrtc | 149 } // namespace webrtc |
OLD | NEW |