Home | History | Annotate | Download | only in auto_test
      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 #ifndef WEBRTC_VOICE_ENGINE_VOE_STANDARD_TEST_H
     12 #define WEBRTC_VOICE_ENGINE_VOE_STANDARD_TEST_H
     13 
     14 #include <stdio.h>
     15 #include <string>
     16 
     17 #include "gflags/gflags.h"
     18 #include "webrtc/voice_engine/include/voe_audio_processing.h"
     19 #include "webrtc/voice_engine/include/voe_base.h"
     20 #include "webrtc/voice_engine/include/voe_dtmf.h"
     21 #include "webrtc/voice_engine/include/voe_errors.h"
     22 #include "webrtc/voice_engine/include/voe_file.h"
     23 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
     24 #include "webrtc/voice_engine/test/auto_test/resource_manager.h"
     25 #include "webrtc/voice_engine/test/auto_test/voe_test_common.h"
     26 #include "webrtc/voice_engine/test/auto_test/voe_test_interface.h"
     27 #ifdef WEBRTC_VOICE_ENGINE_CODEC_API
     28 #include "webrtc/voice_engine/include/voe_codec.h"
     29 #endif
     30 #ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
     31 #include "webrtc/voice_engine/include/voe_external_media.h"
     32 #endif
     33 #ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
     34 #include "webrtc/voice_engine/include/voe_hardware.h"
     35 #endif
     36 #include "webrtc/voice_engine/include/voe_network.h"
     37 #ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
     38 #include "webrtc/voice_engine/include/voe_video_sync.h"
     39 #endif
     40 #ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
     41 #include "webrtc/voice_engine/include/voe_volume_control.h"
     42 #endif
     43 
     44 #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
     45 namespace webrtc {
     46 class CriticalSectionWrapper;
     47 class ThreadWrapper;
     48 class VoENetEqStats;
     49 }
     50 #endif
     51 
     52 #if defined(WEBRTC_ANDROID)
     53 extern char mobileLogMsg[640];
     54 #endif
     55 
     56 DECLARE_bool(include_timing_dependent_tests);
     57 
     58 namespace voetest {
     59 
     60 class SubAPIManager {
     61  public:
     62   SubAPIManager()
     63     : _base(true),
     64       _codec(false),
     65       _dtmf(false),
     66       _externalMedia(false),
     67       _file(false),
     68       _hardware(false),
     69       _netEqStats(false),
     70       _network(false),
     71       _rtp_rtcp(false),
     72       _videoSync(false),
     73       _volumeControl(false),
     74       _apm(false) {
     75 #ifdef WEBRTC_VOICE_ENGINE_CODEC_API
     76       _codec = true;
     77 #endif
     78 #ifdef WEBRTC_VOICE_ENGINE_DTMF_API
     79       _dtmf = true;
     80 #endif
     81 #ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API
     82       _externalMedia = true;
     83 #endif
     84 #ifdef WEBRTC_VOICE_ENGINE_FILE_API
     85       _file = true;
     86 #endif
     87 #ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API
     88       _hardware = true;
     89 #endif
     90 #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
     91       _netEqStats = true;
     92 #endif
     93       _network = true;
     94 #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API
     95       _rtp_rtcp = true;
     96 #endif
     97 #ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API
     98       _videoSync = true;
     99 #endif
    100 #ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API
    101       _volumeControl = true;
    102 #endif
    103 #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
    104       _apm = true;
    105 #endif
    106   }
    107 
    108   void DisplayStatus() const;
    109 
    110  private:
    111   bool _base, _codec, _dtmf;
    112   bool _externalMedia, _file, _hardware;
    113   bool _netEqStats, _network, _rtp_rtcp, _videoSync, _volumeControl, _apm;
    114 };
    115 
    116 class VoETestManager {
    117  public:
    118   VoETestManager();
    119   ~VoETestManager();
    120 
    121   // Must be called after construction.
    122   bool Init();
    123 
    124   void GetInterfaces();
    125   int ReleaseInterfaces();
    126 
    127   const char* AudioFilename() const {
    128     const std::string& result = resource_manager_.long_audio_file_path();
    129     if (result.length() == 0) {
    130       TEST_LOG("ERROR: Failed to open input file!");
    131     }
    132     return result.c_str();
    133   }
    134 
    135   VoiceEngine* VoiceEnginePtr() const {
    136     return voice_engine_;
    137   }
    138   VoEBase* BasePtr() const {
    139     return voe_base_;
    140   }
    141   VoECodec* CodecPtr() const {
    142     return voe_codec_;
    143   }
    144   VoEVolumeControl* VolumeControlPtr() const {
    145     return voe_volume_control_;
    146   }
    147   VoEDtmf* DtmfPtr() const {
    148     return voe_dtmf_;
    149   }
    150   VoERTP_RTCP* RTP_RTCPPtr() const {
    151     return voe_rtp_rtcp_;
    152   }
    153   VoEAudioProcessing* APMPtr() const {
    154     return voe_apm_;
    155   }
    156 
    157   VoENetwork* NetworkPtr() const {
    158     return voe_network_;
    159   }
    160 
    161   VoEFile* FilePtr() const {
    162     return voe_file_;
    163   }
    164 
    165   VoEHardware* HardwarePtr() const {
    166     return voe_hardware_;
    167   }
    168 
    169   VoEVideoSync* VideoSyncPtr() const {
    170     return voe_vsync_;
    171   }
    172 
    173   VoEExternalMedia* ExternalMediaPtr() const {
    174     return voe_xmedia_;
    175   }
    176 
    177 #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
    178   VoENetEqStats* NetEqStatsPtr() const {
    179     return voe_neteq_stats_;
    180   }
    181 #endif
    182 
    183  private:
    184   bool                   initialized_;
    185 
    186   VoiceEngine*           voice_engine_;
    187   VoEBase*               voe_base_;
    188   VoECodec*              voe_codec_;
    189   VoEDtmf*               voe_dtmf_;
    190   VoEExternalMedia*      voe_xmedia_;
    191   VoEFile*               voe_file_;
    192   VoEHardware*           voe_hardware_;
    193   VoENetwork*            voe_network_;
    194 #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API
    195   VoENetEqStats*         voe_neteq_stats_;
    196 #endif
    197   VoERTP_RTCP*           voe_rtp_rtcp_;
    198   VoEVideoSync*          voe_vsync_;
    199   VoEVolumeControl*      voe_volume_control_;
    200   VoEAudioProcessing*    voe_apm_;
    201 
    202   ResourceManager        resource_manager_;
    203 };
    204 
    205 }  // namespace voetest
    206 
    207 #endif // WEBRTC_VOICE_ENGINE_VOE_STANDARD_TEST_H
    208