1/*
2 *  Copyright (c) 2011 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#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTVADDTX_H_
12#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTVADDTX_H_
13
14#include "webrtc/modules/audio_coding/main/test/ACMTest.h"
15#include "webrtc/modules/audio_coding/main/test/Channel.h"
16#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
17#include "webrtc/system_wrappers/interface/scoped_ptr.h"
18
19namespace webrtc {
20
21typedef struct {
22  bool statusDTX;
23  bool statusVAD;
24  ACMVADMode vadMode;
25} VADDTXstruct;
26
27class ActivityMonitor : public ACMVADCallback {
28 public:
29  ActivityMonitor();
30  ~ActivityMonitor();
31  int32_t InFrameType(int16_t frameType);
32  void PrintStatistics();
33  void ResetStatistics();
34  void GetStatistics(uint32_t* getCounter);
35 private:
36  // Counting according to
37  // enum WebRtcACMEncodingType {
38  //   kNoEncoding,
39  //   kActiveNormalEncoded,
40  //   kPassiveNormalEncoded,
41  //   kPassiveDTXNB,
42  //   kPassiveDTXWB,
43  //   kPassiveDTXSWB
44  // };
45  uint32_t _counter[6];
46};
47
48class TestVADDTX : public ACMTest {
49 public:
50  TestVADDTX();
51  ~TestVADDTX();
52
53  void Perform();
54 private:
55  // Registration can be based on codec name only, codec name and sampling
56  //  frequency, or codec name, sampling frequency and rate.
57  int16_t RegisterSendCodec(char side,
58                            char* codecName,
59                            int32_t samplingFreqHz = -1,
60                            int32_t rateKhz = -1);
61  void Run();
62  void OpenOutFile(int16_t testNumber);
63  void runTestCases();
64  void runTestInternalDTX(int expected_result);
65  void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode);
66  VADDTXstruct GetVAD();
67  int16_t VerifyTest();
68  scoped_ptr<AudioCodingModule> _acmA;
69  scoped_ptr<AudioCodingModule> _acmB;
70
71  Channel* _channelA2B;
72
73  PCMFile _inFileA;
74  PCMFile _outFileB;
75
76  ActivityMonitor _monitor;
77  uint32_t _statCounter[6];
78
79  VADDTXstruct _setStruct;
80  VADDTXstruct _getStruct;
81};
82
83}  // namespace webrtc
84
85#endif  // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTVADDTX_H_
86