• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include <stdio.h>
12 #include <string>
13 #include <vector>
14 
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
17 #include "webrtc/modules/audio_coding/test/APITest.h"
18 #include "webrtc/modules/audio_coding/test/EncodeDecodeTest.h"
19 #include "webrtc/modules/audio_coding/test/iSACTest.h"
20 #include "webrtc/modules/audio_coding/test/opus_test.h"
21 #include "webrtc/modules/audio_coding/test/PacketLossTest.h"
22 #include "webrtc/modules/audio_coding/test/TestAllCodecs.h"
23 #include "webrtc/modules/audio_coding/test/TestRedFec.h"
24 #include "webrtc/modules/audio_coding/test/TestStereo.h"
25 #include "webrtc/modules/audio_coding/test/TestVADDTX.h"
26 #include "webrtc/modules/audio_coding/test/TwoWayCommunication.h"
27 #include "webrtc/system_wrappers/include/trace.h"
28 #include "webrtc/test/testsupport/fileutils.h"
29 
30 using webrtc::Trace;
31 
32 // This parameter is used to describe how to run the tests. It is normally
33 // set to 0, and all tests are run in quite mode.
34 #define ACM_TEST_MODE 0
35 
TEST(AudioCodingModuleTest,TestAllCodecs)36 TEST(AudioCodingModuleTest, TestAllCodecs) {
37   Trace::CreateTrace();
38   Trace::SetTraceFile((webrtc::test::OutputPath() +
39           "acm_allcodecs_trace.txt").c_str());
40   webrtc::TestAllCodecs(ACM_TEST_MODE).Perform();
41   Trace::ReturnTrace();
42 }
43 
44 #if defined(WEBRTC_ANDROID)
TEST(AudioCodingModuleTest,DISABLED_TestEncodeDecode)45 TEST(AudioCodingModuleTest, DISABLED_TestEncodeDecode) {
46 #else
47 TEST(AudioCodingModuleTest, TestEncodeDecode) {
48 #endif
49   Trace::CreateTrace();
50   Trace::SetTraceFile((webrtc::test::OutputPath() +
51       "acm_encodedecode_trace.txt").c_str());
52   webrtc::EncodeDecodeTest(ACM_TEST_MODE).Perform();
53   Trace::ReturnTrace();
54 }
55 
56 #if defined(WEBRTC_CODEC_RED)
57 #if defined(WEBRTC_ANDROID)
58 TEST(AudioCodingModuleTest, DISABLED_TestRedFec) {
59 #else
60 TEST(AudioCodingModuleTest, TestRedFec) {
61 #endif
62   Trace::CreateTrace();
63   Trace::SetTraceFile((webrtc::test::OutputPath() +
64       "acm_fec_trace.txt").c_str());
65   webrtc::TestRedFec().Perform();
66   Trace::ReturnTrace();
67 }
68 #endif
69 
70 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
71 #if defined(WEBRTC_ANDROID)
72 TEST(AudioCodingModuleTest, DISABLED_TestIsac) {
73 #else
74 TEST(AudioCodingModuleTest, TestIsac) {
75 #endif
76   Trace::CreateTrace();
77   Trace::SetTraceFile((webrtc::test::OutputPath() +
78       "acm_isac_trace.txt").c_str());
79   webrtc::ISACTest(ACM_TEST_MODE).Perform();
80   Trace::ReturnTrace();
81 }
82 #endif
83 
84 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \
85     defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722)
86 #if defined(WEBRTC_ANDROID)
87 TEST(AudioCodingModuleTest, DISABLED_TwoWayCommunication) {
88 #else
89 TEST(AudioCodingModuleTest, TwoWayCommunication) {
90 #endif
91   Trace::CreateTrace();
92   Trace::SetTraceFile((webrtc::test::OutputPath() +
93       "acm_twowaycom_trace.txt").c_str());
94   webrtc::TwoWayCommunication(ACM_TEST_MODE).Perform();
95   Trace::ReturnTrace();
96 }
97 #endif
98 
99 #if defined(WEBRTC_ANDROID)
100 TEST(AudioCodingModuleTest, DISABLED_TestStereo) {
101 #else
102 TEST(AudioCodingModuleTest, TestStereo) {
103 #endif
104   Trace::CreateTrace();
105   Trace::SetTraceFile((webrtc::test::OutputPath() +
106       "acm_stereo_trace.txt").c_str());
107   webrtc::TestStereo(ACM_TEST_MODE).Perform();
108   Trace::ReturnTrace();
109 }
110 
111 #if defined(WEBRTC_ANDROID)
112 TEST(AudioCodingModuleTest, DISABLED_TestWebRtcVadDtx) {
113 #else
114 TEST(AudioCodingModuleTest, TestWebRtcVadDtx) {
115 #endif
116   Trace::CreateTrace();
117   Trace::SetTraceFile((webrtc::test::OutputPath() +
118       "acm_vaddtx_trace.txt").c_str());
119   webrtc::TestWebRtcVadDtx().Perform();
120   Trace::ReturnTrace();
121 }
122 
123 TEST(AudioCodingModuleTest, TestOpusDtx) {
124   Trace::CreateTrace();
125   Trace::SetTraceFile((webrtc::test::OutputPath() +
126       "acm_opusdtx_trace.txt").c_str());
127   webrtc::TestOpusDtx().Perform();
128   Trace::ReturnTrace();
129 }
130 
131 TEST(AudioCodingModuleTest, TestOpus) {
132   Trace::CreateTrace();
133   Trace::SetTraceFile((webrtc::test::OutputPath() +
134       "acm_opus_trace.txt").c_str());
135   webrtc::OpusTest().Perform();
136   Trace::ReturnTrace();
137 }
138 
139 TEST(AudioCodingModuleTest, TestPacketLoss) {
140   Trace::CreateTrace();
141   Trace::SetTraceFile((webrtc::test::OutputPath() +
142       "acm_packetloss_trace.txt").c_str());
143   webrtc::PacketLossTest(1, 10, 10, 1).Perform();
144   Trace::ReturnTrace();
145 }
146 
147 TEST(AudioCodingModuleTest, TestPacketLossBurst) {
148   Trace::CreateTrace();
149   Trace::SetTraceFile((webrtc::test::OutputPath() +
150       "acm_packetloss_burst_trace.txt").c_str());
151   webrtc::PacketLossTest(1, 10, 10, 2).Perform();
152   Trace::ReturnTrace();
153 }
154 
155 TEST(AudioCodingModuleTest, TestPacketLossStereo) {
156   Trace::CreateTrace();
157   Trace::SetTraceFile((webrtc::test::OutputPath() +
158       "acm_packetloss_trace.txt").c_str());
159   webrtc::PacketLossTest(2, 10, 10, 1).Perform();
160   Trace::ReturnTrace();
161 }
162 
163 TEST(AudioCodingModuleTest, TestPacketLossStereoBurst) {
164   Trace::CreateTrace();
165   Trace::SetTraceFile((webrtc::test::OutputPath() +
166       "acm_packetloss_burst_trace.txt").c_str());
167   webrtc::PacketLossTest(2, 10, 10, 2).Perform();
168   Trace::ReturnTrace();
169 }
170 
171 // The full API test is too long to run automatically on bots, but can be used
172 // for offline testing. User interaction is needed.
173 #ifdef ACM_TEST_FULL_API
174   TEST(AudioCodingModuleTest, TestAPI) {
175     Trace::CreateTrace();
176     Trace::SetTraceFile((webrtc::test::OutputPath() +
177         "acm_apitest_trace.txt").c_str());
178     webrtc::APITest().Perform();
179     Trace::ReturnTrace();
180   }
181 #endif
182