Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: webrtc/audio/test/low_bandwidth_audio_test.cc

Issue 2694203002: Low-bandwidth audio testing (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 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 // This is a placeholder for the work oprypin@ is doing on a low-bandwidth 11 #include <algorithm>
12 // audio test executable.
13 12
14 int main() { 13 #include "webrtc/audio/test/low_bandwidth_audio_test.h"
14 #include "webrtc/common_audio/wav_file.h"
15 #include "webrtc/test/gtest.h"
16 #include "webrtc/test/run_test.h"
17 #include "webrtc/system_wrappers/include/sleep.h"
18 #include "webrtc/test/testsupport/fileutils.h"
19
20 namespace {
21 // Wait half a second between stopping sending and stopping receiving audio.
22 constexpr int kExtraRecordTimeMs = 500;
23
24 // Large bitrate by default.
25 const webrtc::CodecInst kDefaultCodec{120, "OPUS", 48000, 960, 2, 64000};
26
27 // The best that can be done with PESQ.
28 constexpr int kAudioFileBitRate = 16000;
29 }
30
31 namespace webrtc {
32 namespace test {
33
34 AudioQualityTest::AudioQualityTest()
35 : EndToEndTest(CallTest::kDefaultTimeoutMs) {}
36
37 size_t AudioQualityTest::GetNumVideoStreams() const {
15 return 0; 38 return 0;
16 } 39 }
40 size_t AudioQualityTest::GetNumAudioStreams() const {
41 return 1;
42 }
43 size_t AudioQualityTest::GetNumFlexfecStreams() const {
44 return 0;
45 }
46
47 std::string AudioQualityTest::AudioInputFile() {
48 return test::ResourcePath("voice_engine/audio_tiny16", "wav");
49 }
50
51 std::string AudioQualityTest::AudioOutputFile() {
52 const ::testing::TestInfo* const test_info =
53 ::testing::UnitTest::GetInstance()->current_test_info();
54 return webrtc::test::OutputPath() +
55 "LowBandwidth_" + test_info->name() + ".wav";
56 }
57
58 std::unique_ptr<test::FakeAudioDevice::Capturer>
59 AudioQualityTest::CreateCapturer() {
60 return test::FakeAudioDevice::CreateWavFileReader(AudioInputFile());
61 }
62
63 std::unique_ptr<test::FakeAudioDevice::Renderer>
64 AudioQualityTest::CreateRenderer() {
65 return test::FakeAudioDevice::CreateBoundedWavFileWriter(
66 AudioOutputFile(), kAudioFileBitRate);
67 }
68
69 void AudioQualityTest::OnFakeAudioDevicesCreated(
70 test::FakeAudioDevice* send_audio_device,
71 test::FakeAudioDevice* recv_audio_device) {
72 send_audio_device_ = send_audio_device;
73 }
74
75 FakeNetworkPipe::Config AudioQualityTest::GetNetworkPipeConfig() {
76 return FakeNetworkPipe::Config();
77 }
78
79 test::PacketTransport* AudioQualityTest::CreateSendTransport(
80 Call* sender_call) {
81 return new test::PacketTransport(
82 sender_call, this, test::PacketTransport::kSender,
83 GetNetworkPipeConfig());
84 }
85
86 test::PacketTransport* AudioQualityTest::CreateReceiveTransport() {
87 return new test::PacketTransport(nullptr, this,
88 test::PacketTransport::kReceiver, GetNetworkPipeConfig());
89 }
90
91 void AudioQualityTest::ModifyAudioConfigs(
92 AudioSendStream::Config* send_config,
93 std::vector<AudioReceiveStream::Config>* receive_configs) {
94 send_config->send_codec_spec.codec_inst = kDefaultCodec;
95 }
96
97 void AudioQualityTest::PerformTest() {
98 // Wait until the input audio file is done...
99 send_audio_device_->WaitForRecordingEnd();
100 // and some extra time to account for network delay.
101 SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraRecordTimeMs);
102 }
103
104 void AudioQualityTest::OnTestFinished() {
105 const ::testing::TestInfo* const test_info =
106 ::testing::UnitTest::GetInstance()->current_test_info();
107
108 // Output information about the input and output audio files so that further
109 // processing can be done by an external process.
110 printf("TEST %s %s:%s\n", test_info->name(),
111 AudioInputFile().c_str(), AudioOutputFile().c_str());
112 }
113
114
115 using LowBandwidthAudioTest = CallTest;
116
117 TEST_F(LowBandwidthAudioTest, GoodNetworkHighBitrate) {
118 AudioQualityTest test;
119 RunBaseTest(&test);
120 }
121
122
123 class Mobile2GNetworkTest : public AudioQualityTest {
124 void ModifyAudioConfigs(AudioSendStream::Config* send_config,
125 std::vector<AudioReceiveStream::Config>* receive_configs) override {
126 send_config->send_codec_spec.codec_inst = CodecInst{
127 120, // pltype
128 "OPUS", // plname
129 48000, // plfreq
130 2880, // pacsize
131 1, // channels
132 6000 // rate bits/sec
133 };
134 }
135
136 FakeNetworkPipe::Config GetNetworkPipeConfig() override {
137 FakeNetworkPipe::Config pipe_config;
138 pipe_config.link_capacity_kbps = 12;
139 pipe_config.queue_length_packets = 1500;
140 pipe_config.queue_delay_ms = 400;
141 return pipe_config;
142 }
143 };
144
145 TEST_F(LowBandwidthAudioTest, Mobile2GNetwork) {
146 Mobile2GNetworkTest test;
147 RunBaseTest(&test);
148 }
149
150 } // namespace test
151 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/test/low_bandwidth_audio_test.h ('k') | webrtc/audio/test/low_bandwidth_audio_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698