• 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 "webrtc/voice_engine/test/auto_test/voe_cpu_test.h"
12 
13 #include <stdio.h>
14 #include <string.h>
15 #include <time.h>
16 #if defined(_WIN32)
17 #include <conio.h>
18 #endif
19 
20 #include "webrtc/base/scoped_ptr.h"
21 #include "webrtc/test/channel_transport/channel_transport.h"
22 #include "webrtc/voice_engine/test/auto_test/voe_test_defines.h"
23 
24 using namespace webrtc;
25 using namespace test;
26 
27 namespace voetest {
28 
29 #define CHECK(expr)                                             \
30     if (expr)                                                   \
31     {                                                           \
32         printf("Error at line: %i, %s \n", __LINE__, #expr);    \
33         printf("Error code: %i \n", base->LastError());  \
34         PAUSE												    \
35         return -1;                                              \
36     }
37 
VoECpuTest(VoETestManager & mgr)38 VoECpuTest::VoECpuTest(VoETestManager& mgr)
39     : _mgr(mgr) {
40 
41 }
42 
DoTest()43 int VoECpuTest::DoTest() {
44   printf("------------------------------------------------\n");
45   printf(" CPU Reference Test\n");
46   printf("------------------------------------------------\n");
47 
48   VoEBase* base = _mgr.BasePtr();
49   VoEFile* file = _mgr.FilePtr();
50   VoECodec* codec = _mgr.CodecPtr();
51   VoEAudioProcessing* apm = _mgr.APMPtr();
52   VoENetwork* voe_network = _mgr.NetworkPtr();
53 
54   int channel(-1);
55   CodecInst isac;
56 
57   isac.pltype = 104;
58   strcpy(isac.plname, "ISAC");
59   isac.pacsize = 960;
60   isac.plfreq = 32000;
61   isac.channels = 1;
62   isac.rate = -1;
63 
64   CHECK(base->Init());
65   channel = base->CreateChannel();
66 
67   rtc::scoped_ptr<VoiceChannelTransport> voice_socket_transport(
68       new VoiceChannelTransport(voe_network, channel));
69 
70   CHECK(voice_socket_transport->SetSendDestination("127.0.0.1", 5566));
71   CHECK(voice_socket_transport->SetLocalReceiver(5566));
72 
73   CHECK(codec->SetRecPayloadType(channel, isac));
74   CHECK(codec->SetSendCodec(channel, isac));
75 
76   CHECK(base->StartReceive(channel));
77   CHECK(base->StartPlayout(channel));
78   CHECK(base->StartSend(channel));
79   CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(),
80           true, true));
81 
82   CHECK(codec->SetVADStatus(channel, true));
83   CHECK(apm->SetAgcStatus(true, kAgcAdaptiveAnalog));
84   CHECK(apm->SetNsStatus(true, kNsModerateSuppression));
85   CHECK(apm->SetEcStatus(true, kEcAec));
86 
87   TEST_LOG("\nMeasure CPU and memory while running a full-duplex"
88     " iSAC-swb call.\n\n");
89 
90   PAUSE
91 
92   CHECK(base->StopSend(channel));
93   CHECK(base->StopPlayout(channel));
94   CHECK(base->StopReceive(channel));
95 
96   base->DeleteChannel(channel);
97   CHECK(base->Terminate());
98   return 0;
99 }
100 
101 }  // namespace voetest
102