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