diff --git a/src/voice_engine/main/test/auto_test/voe_cpu_test.cc b/src/voice_engine/main/test/auto_test/voe_cpu_test.cc index fb14d3613..e93783bc1 100644 --- a/src/voice_engine/main/test/auto_test/voe_cpu_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_cpu_test.cc @@ -22,12 +22,6 @@ using namespace webrtc; namespace voetest { -#ifdef MAC_IPHONE -extern char micFile[256]; -#else -extern const char* micFile; -#endif - #define CHECK(expr) \ if (expr) \ { \ @@ -81,7 +75,8 @@ int VoECpuTest::DoTest() CHECK(base->StartReceive(channel)); CHECK(base->StartPlayout(channel)); CHECK(base->StartSend(channel)); - CHECK(file->StartPlayingFileAsMicrophone(channel, micFile, true, true)); + CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), + true, true)); CHECK(codec->SetVADStatus(channel, true)); CHECK(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); diff --git a/src/voice_engine/main/test/auto_test/voe_extended_test.cc b/src/voice_engine/main/test/auto_test/voe_extended_test.cc index d98e44ef0..ed5ba11ef 100644 --- a/src/voice_engine/main/test/auto_test/voe_extended_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_extended_test.cc @@ -43,10 +43,8 @@ const char* RemoteIP = "192.168.200.1"; // transmit to this IP address #ifdef MAC_IPHONE #define SLEEP_IF_IPHONE(x) SLEEP(x) -extern char micFile[256]; #else #define SLEEP_IF_IPHONE(x) -extern const char* micFile; #endif #ifdef WEBRTC_ANDROID @@ -355,7 +353,8 @@ void VoEExtendedTest::Play(int channel, fflush(NULL); if (addFileAsMicrophone) { - file->StartPlayingFileAsMicrophone(channel, micFile, true, true); + file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), true, + true); TEST_LOG("[file as mic]"); fflush(NULL); } @@ -1677,7 +1676,8 @@ int VoEExtendedTest::TestCallReport() TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartSend(0)); TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); /////////////////////////// // Actual test starts here @@ -2636,8 +2636,10 @@ int VoEExtendedTest::TestCodec() TEST_MUSTPASS(base->StartSend(0)); if (file) { - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, - true, true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + _mgr.AudioFilename(), + true, + true)); } // Scan all supported and valid codecs and remove from receiving db, then @@ -3658,7 +3660,8 @@ int VoEExtendedTest::TestEncryption() TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartSend(0)); TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); /////////////////////////// // Actual test starts here @@ -3913,7 +3916,8 @@ int VoEExtendedTest::TestEncryption() TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartPlayout(0)); TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); MARK(); SLEEP(2000); TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); @@ -5888,7 +5892,8 @@ int VoEExtendedTest::TestNetwork() TEST_MUSTPASS(base->SetSendDestination(0, 8000, "::1")); TEST_MUSTPASS(base->StartPlayout(0)); TEST_MUSTPASS(base->StartSend(0)); - file->StartPlayingFileAsMicrophone(0, micFile, true ,true); + file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), true, + true); SLEEP(500); // ensure that we receieve some packets // SetSourceFilter and GetSourceFilter @@ -6969,7 +6974,8 @@ int VoEExtendedTest::TestRTP_RTCP() MARK(); ANL(); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); // ------------------------------------------------------------------------ // >> InsertExtraRTPPacket @@ -7005,7 +7011,8 @@ int VoEExtendedTest::TestRTP_RTCP() MARK(); // not sending TEST_ERROR(VE_NOT_SENDING); TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); SLEEP(1000); for (int p = 0; p < 128; p++) @@ -7213,7 +7220,8 @@ int VoEExtendedTest::TestRTP_RTCP() TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartSend(0)); TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); SLEEP(8000); @@ -7467,7 +7475,8 @@ TEST(RTCPStatistics #2); TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartSend(0)); TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true, 126)); MARK(); TEST_LOG("Should sound OK with FEC enabled\n"); @@ -7636,7 +7645,8 @@ int VoEExtendedTest::TestVolumeControl() TEST_MUSTPASS(base->StartPlayout(0)); TEST_MUSTPASS(base->StartSend(0)); #ifdef _TEST_FILE_ - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true ,true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); #endif //////////////////////////// diff --git a/src/voice_engine/main/test/auto_test/voe_standard_test.cc b/src/voice_engine/main/test/auto_test/voe_standard_test.cc index e0cf2b6d4..7de3983f0 100644 --- a/src/voice_engine/main/test/auto_test/voe_standard_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_standard_test.cc @@ -29,9 +29,10 @@ #include "../../source/voice_engine_defines.h" // defines build macros #endif -#include "thread_wrapper.h" #include "critical_section_wrapper.h" #include "event_wrapper.h" +#include "thread_wrapper.h" +#include "testsupport/fileutils.h" #ifdef _TEST_NETEQ_STATS_ #include "../../interface/voe_neteq_stats.h" // Not available in delivery folder @@ -44,7 +45,7 @@ using namespace webrtc; -namespace voetest{ +namespace voetest { #ifdef MAC_IPHONE // Defined in iPhone specific test file @@ -128,7 +129,7 @@ char* GetResource(char* resource) return filenameStr[currentStr]; } const char* GetResource(const char* resource) -{ +{ currentStr = !currentStr; sprintf(filenameStr[currentStr], "/tmp/%s", @@ -137,25 +138,6 @@ const char* GetResource(const char* resource) } #endif -#if defined(MAC_IPHONE) -char micFile[256] = {0}; // Filename copied to buffer in code -#elif defined(WEBRTC_MAC) && !defined(WEBRTC_MAC_INTEL) -const char* micFile = "audio_long16bigendian.pcm"; -#elif defined(WEBRTC_ANDROID) -const char* micFile = "/sdcard/audio_long16.pcm"; -#elif defined(_WIN32) -// File path is relative to the location of 'voice_engine.gyp'. -const char* micFile = "../../test/data/voice_engine/audio_long16.pcm"; -#elif defined(WEBRTC_LINUX) -// Assumes launch from command line: $ ./out//audio_device_test_func -const char* micFile = "./test/data/voice_engine/audio_long16.pcm"; -#elif (defined(WEBRTC_MAC_INTEL) || defined(WEBRTC_MAC)) -// Assumes that the working directory in Xcode is set to /xcodebuild/. -const char* micFile = "../../test/data/voice_engine/audio_long16.pcm"; -#else -const char* micFile = "audio_long16.pcm"; -#endif - #if !defined(MAC_IPHONE) const char* summaryFilename = "/tmp/VoiceEngineSummary.txt"; @@ -596,6 +578,7 @@ bool SubAPIManager::GetExtendedMenuSelection(ExtendedSelection& sel) } VoETestManager::VoETestManager() : + initialized_(false), ve(0), base(0), report(0), @@ -606,31 +589,57 @@ VoETestManager::VoETestManager() : file(0), hardware(0), #ifdef _TEST_NETEQ_STATS_ - neteqst(0), + neteqst(NULL), #endif netw(0), rtp_rtcp(0), vsync(0), volume(0), apm(0), - instanceCount(0) + instanceCount(0), + resourcePath_(), + audioFilename_() +{} + +VoETestManager::~VoETestManager() +{} + +bool VoETestManager::Init() { + if (initialized_) + return true; + if (VoiceEngine::SetTraceFile(NULL) != -1) { // should not be possible to call a Trace method before the VoE is // created TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" "should fail)!\n", __LINE__); + return false; } -#ifdef _TEST_NETEQ_STATS_ - neteqst = 0; -#endif - ve = VoiceEngine::Create(); - instanceCount++; -}; -VoETestManager::~VoETestManager() -{ +#if defined(WEBRTC_ANDROID) + resourcePath_ = "/sdcard/"; +#else + resourcePath_ = webrtc::test::GetProjectRootPath(); + if (resourcePath_ == webrtc::test::kCannotFindProjectRootDir) + { + TEST_LOG("Failed to get project root directory\n"); + return false; + } + resourcePath_ += "test/data/voice_engine/"; +#endif + audioFilename_ = resourcePath_ + "audio_long16.pcm"; + + ve = VoiceEngine::Create(); + if (!ve) + { + TEST_LOG("Failed to create VoiceEngine\n"); + return false; + } + instanceCount++; + + return true; } void VoETestManager::GetInterfaces() @@ -1322,7 +1331,7 @@ int VoETestManager::DoStandardTest() TEST_LOG("Start playing a file as microphone, so you don't need to" " speak all the time\n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); SLEEP(1000); @@ -1343,7 +1352,8 @@ int VoETestManager::DoStandardTest() { TEST_LOG("Start playing a file locally => " "you should now hear this file being played out \n"); - TEST_MUSTPASS(file->StartPlayingFileLocally(0, micFile, true)); + TEST_MUSTPASS(file->StartPlayingFileLocally(0, AudioFilename(), + true)); SLEEP(2000); } TEST_LOG("Put playing on hold => should *not* hear audio \n"); @@ -1680,10 +1690,8 @@ int VoETestManager::DoStandardTest() if (file) { TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, - true, - true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, AudioFilename(), true, true)); } #else TEST_LOG("Skipping extended iSAC API tests - " @@ -1923,7 +1931,7 @@ int VoETestManager::DoStandardTest() { TEST_LOG("Start playing a file as microphone again...\n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); } @@ -2247,10 +2255,8 @@ int VoETestManager::DoStandardTest() TEST_MUSTPASS(base->StartPlayout(0)); TEST_MUSTPASS(base->StartSend(0)); TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, - true, - true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, AudioFilename(), true, true)); break; } } @@ -2413,7 +2419,7 @@ int VoETestManager::DoStandardTest() { TEST_LOG("==> Start playing a file as microphone again \n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); SLEEP(1000); @@ -2854,10 +2860,8 @@ int VoETestManager::DoStandardTest() if (file) { TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, - true, - true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, AudioFilename(), true, true)); } else { @@ -2989,7 +2993,8 @@ int VoETestManager::DoStandardTest() TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true , true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, AudioFilename(), + true, true)); #else TEST_LOG("\n\n+++ File tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_FILE_ @@ -3135,7 +3140,7 @@ int VoETestManager::DoStandardTest() { TEST_LOG("Start playing a file as microphone again \n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); } @@ -3160,7 +3165,7 @@ int VoETestManager::DoStandardTest() { TEST_LOG("Start playing a file as microphone again \n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); } @@ -3211,7 +3216,7 @@ int VoETestManager::DoStandardTest() TEST_LOG("Start playing a file as microphone again using" " external transport\n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); } @@ -3233,7 +3238,9 @@ int VoETestManager::DoStandardTest() if (file) { TEST_LOG("Start playing a file as microphone again using transport\n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true, + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, true)); } SLEEP(2000); @@ -3328,7 +3335,7 @@ int VoETestManager::DoStandardTest() { TEST_LOG("Start playing a file as microphone again \n"); TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - micFile, + AudioFilename(), true, true)); } @@ -3522,7 +3529,8 @@ int VoETestManager::DoStandardTest() TEST_MUSTPASS(base->StartSend(0)); TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, micFile, true , true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, AudioFilename(), + true, true)); #else TEST_LOG("Skipping external rec and playout tests - \ WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT not defined \n"); @@ -3647,7 +3655,6 @@ int VoETestManager::DoStandardTest() TEST_LOG("\n\n+++ NetEQ statistics tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_NETEQ_STATS_ - ////////////////// // Stop streaming @@ -3672,19 +3679,14 @@ int runAutoTest(TestType testType, ExtendedSelection extendedSel) SubAPIManager apiMgr; apiMgr.DisplayStatus(); -#ifdef MAC_IPHONE - // Write mic file path to buffer - TEST_LOG("Get mic file path \n"); - if (0 != GetResource("audio_long16.pcm", micFile, 256)) - { - TEST_LOG("Failed get mic file path! \n"); - } -#endif - //////////////////////////////////// // Create VoiceEngine and sub API:s voetest::VoETestManager tm; + if (!tm.Init()) + { + return -1; + } tm.GetInterfaces(); ////////////////////// diff --git a/src/voice_engine/main/test/auto_test/voe_standard_test.h b/src/voice_engine/main/test/auto_test/voe_standard_test.h index 39ef35765..908c876df 100644 --- a/src/voice_engine/main/test/auto_test/voe_standard_test.h +++ b/src/voice_engine/main/test/auto_test/voe_standard_test.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_VOICE_ENGINE_VOE_STANDARD_TEST_H #define WEBRTC_VOICE_ENGINE_VOE_STANDARD_TEST_H +#include + #include "voe_test_defines.h" #include "voe_test_interface.h" @@ -282,10 +284,18 @@ public: VoETestManager(); ~VoETestManager(); + // Must be called after construction. + bool Init(); + void GetInterfaces(); int ReleaseInterfaces(); int DoStandardTest(); + const char* AudioFilename() const + { + return audioFilename_.c_str(); + } + VoiceEngine* VoiceEnginePtr() const { return ve; @@ -350,6 +360,7 @@ public: #endif private: + bool initialized_; VoiceEngine* ve; VoEBase* base; VoECallReport* report; @@ -368,6 +379,8 @@ private: VoEVolumeControl* volume; VoEAudioProcessing* apm; int instanceCount; + std::string resourcePath_; + std::string audioFilename_; }; } // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_unit_test.cc b/src/voice_engine/main/test/auto_test/voe_unit_test.cc index c99c516a4..0775b5589 100644 --- a/src/voice_engine/main/test/auto_test/voe_unit_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_unit_test.cc @@ -25,12 +25,6 @@ using namespace webrtc; namespace voetest { -#ifdef MAC_IPHONE -extern char micFile[256]; -#else -extern const char* micFile; -#endif - #define CHECK(expr) \ if (expr) \ { \ @@ -295,7 +289,7 @@ int VoEUnitTest::MenuSelection() // StartMedia // ---------------------------------------------------------------------------- -int VoEUnitTest::StartMedia(int channel, +int VoEUnitTest::StartMedia(int channel, int rtpPort, bool listen, bool playout, @@ -332,7 +326,7 @@ int VoEUnitTest::StartMedia(int channel, // play mic as file, mix with microphone to ensure that SWB can be //tested as well const bool mixWithMic(true); - CHECK(file->StartPlayingFileAsMicrophone(channel, micFile, + CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), true, mixWithMic)); } if (localFile) diff --git a/src/voice_engine/main/test/voice_engine_tests.gypi b/src/voice_engine/main/test/voice_engine_tests.gypi index f19cd44fd..2581e200f 100644 --- a/src/voice_engine/main/test/voice_engine_tests.gypi +++ b/src/voice_engine/main/test/voice_engine_tests.gypi @@ -15,6 +15,7 @@ 'dependencies': [ 'voice_engine_core', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/../test/test.gyp:test_support', ], 'include_dirs': [ 'auto_test',