DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
/*
 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef MODULES_AUDIO_CODING_TEST_APITEST_H_
#define MODULES_AUDIO_CODING_TEST_APITEST_H_

#include <memory>

#include "modules/audio_coding/include/audio_coding_module.h"
#include "modules/audio_coding/test/ACMTest.h"
#include "modules/audio_coding/test/Channel.h"
#include "modules/audio_coding/test/PCMFile.h"
#include "modules/audio_coding/test/utility.h"
#include "system_wrappers/include/event_wrapper.h"
#include "system_wrappers/include/rw_lock_wrapper.h"

namespace webrtc {

enum APITESTAction {
  TEST_CHANGE_CODEC_ONLY = 0,
  DTX_TEST = 1
};

class APITest : public ACMTest {
 public:
  APITest();
  ~APITest();

  void Perform();
 private:
  int16_t SetUp();

  static bool PushAudioThreadA(void* obj);
  static bool PullAudioThreadA(void* obj);
  static bool ProcessThreadA(void* obj);
  static bool APIThreadA(void* obj);

  static bool PushAudioThreadB(void* obj);
  static bool PullAudioThreadB(void* obj);
  static bool ProcessThreadB(void* obj);
  static bool APIThreadB(void* obj);

  void CheckVADStatus(char side);

  // Set Min delay, get delay, playout timestamp
  void TestDelay(char side);

  // Unregister a codec & register again.
  void TestRegisteration(char side);

  // Playout Mode, background noise mode.
  // Receiver Frequency, playout frequency.
  void TestPlayout(char receiveSide);

  //
  void TestSendVAD(char side);

  void CurrentCodec(char side);

  void ChangeCodec(char side);

  void Wait(uint32_t waitLengthMs);

  void RunTest(char thread);

  bool PushAudioRunA();
  bool PullAudioRunA();
  bool ProcessRunA();
  bool APIRunA();

  bool PullAudioRunB();
  bool PushAudioRunB();
  bool ProcessRunB();
  bool APIRunB();

  //--- ACMs
  std::unique_ptr<AudioCodingModule> _acmA;
  std::unique_ptr<AudioCodingModule> _acmB;

  //--- Channels
  Channel* _channel_A2B;
  Channel* _channel_B2A;

  //--- I/O files
  // A
  PCMFile _inFileA;
  PCMFile _outFileA;
  // B
  PCMFile _outFileB;
  PCMFile _inFileB;

  //--- I/O params
  // A
  int32_t _outFreqHzA;
  // B
  int32_t _outFreqHzB;

  // Should we write to file.
  // we might skip writing to file if we
  // run the test for a long time.
  bool _writeToFile;
  //--- Events
  // A
  EventTimerWrapper* _pullEventA;      // pulling data from ACM
  EventTimerWrapper* _pushEventA;      // pushing data to ACM
  EventTimerWrapper* _processEventA;   // process
  EventWrapper* _apiEventA;       // API calls
  // B
  EventTimerWrapper* _pullEventB;      // pulling data from ACM
  EventTimerWrapper* _pushEventB;      // pushing data to ACM
  EventTimerWrapper* _processEventB;   // process
  EventWrapper* _apiEventB;       // API calls

  // keep track of the codec in either side.
  uint8_t _codecCntrA;
  uint8_t _codecCntrB;

  // Is set to true if there is no encoder in either side
  bool _thereIsEncoderA;
  bool _thereIsEncoderB;
  bool _thereIsDecoderA;
  bool _thereIsDecoderB;

  bool _sendVADA;
  bool _sendDTXA;
  ACMVADMode _sendVADModeA;

  bool _sendVADB;
  bool _sendDTXB;
  ACMVADMode _sendVADModeB;

  int32_t _minDelayA;
  int32_t _minDelayB;
  bool _payloadUsed[32];

  bool _verbose;

  int _dotPositionA;
  int _dotMoveDirectionA;
  int _dotPositionB;
  int _dotMoveDirectionB;

  char _movingDot[41];

  VADCallback* _vadCallbackA;
  VADCallback* _vadCallbackB;
  RWLockWrapper& _apiTestRWLock;
  bool _randomTest;
  int _testNumA;
  int _testNumB;
};

}  // namespace webrtc

#endif  // MODULES_AUDIO_CODING_TEST_APITEST_H_