From 24e5a83d217867099d3b4770fc2495d00fa7aeca Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Mon, 24 Dec 2018 13:01:38 +0200 Subject: [PATCH] - more fixes & improvements for pcap2wav windows build --- src/CMakeLists.txt | 4 ++-- src/engine/helper/HL_File.cpp | 15 +++++++++++++++ src/engine/helper/HL_File.h | 2 ++ src/engine/helper/HL_Process.cpp | 7 +++++-- src/engine/helper/HL_Sync.cpp | 10 ++++++++++ src/engine/helper/HL_Sync.h | 1 + 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff44cb91..7c6cfa8c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,10 +110,10 @@ add_subdirectory(${rtphone_libs}/webrtc) set(LIBS ice_stack jrtplib g729_codec gsm_codec gsmhr_codec g722_codec srtp resiprocate helper_lib audio_lib webrtc speexdsp - uuid dl) + uuid) if (CMAKE_SYSTEM MATCHES "Win*") - set (LIBS ${LIBS} ssleay32 libeay32 opus silk_float celt) + set (LIBS ${LIBS} opus ) else (CMAKE_SYSTEM MATCHES "Win*") set (LIBS ${LIBS} dl opus uuid) endif (CMAKE_SYSTEM MATCHES "Win*") diff --git a/src/engine/helper/HL_File.cpp b/src/engine/helper/HL_File.cpp index edb90892..2a4ecb6a 100644 --- a/src/engine/helper/HL_File.cpp +++ b/src/engine/helper/HL_File.cpp @@ -58,6 +58,21 @@ bool FileHelper::isAbsolute(const std::string& s) return s.front() == '/' || s.front() == '\\'; } +std::string FileHelper::getCurrentDir() +{ +#if defined(TARGET_WIN) + return std::string(); +#endif + +#if defined(TARGET_LINUX) || defined(TARGET_OSX) + char buffer[512]; + if (getcwd(buf, sizeof buf) != nullptr) + return buf; + else + return std::string(); +#endif +} + std::string FileHelper::addTrailingSlash(const std::string& s) { if (s.empty()) diff --git a/src/engine/helper/HL_File.h b/src/engine/helper/HL_File.h index 857073b5..0911ac82 100644 --- a/src/engine/helper/HL_File.h +++ b/src/engine/helper/HL_File.h @@ -15,6 +15,8 @@ public: static std::string gettempname(); static bool isAbsolute(const std::string& s); + static std::string getCurrentDir(); + static std::string addTrailingSlash(const std::string& s); static std::string mergePathes(const std::string& s1, const std::string& s2); }; diff --git a/src/engine/helper/HL_Process.cpp b/src/engine/helper/HL_Process.cpp index 1193c67e..f8f94328 100644 --- a/src/engine/helper/HL_Process.cpp +++ b/src/engine/helper/HL_Process.cpp @@ -81,6 +81,7 @@ std::string OsProcess::execCommand(const std::string& cmd) std::shared_ptr OsProcess::asyncExecCommand(const std::string& cmdline, std::function callback, + std::function finished_callback, bool& finish_flag) { std::string output; @@ -117,7 +118,8 @@ std::shared_ptr OsProcess::asyncExecCommand(const std::string& cmdl return std::shared_ptr(); } - std::shared_ptr r = std::make_shared([&finish_flag, pi, callback, hPipeRead, hPipeWrite]() + std::shared_ptr r = std::make_shared( + [&finish_flag, pi, callback, finished_callback, hPipeRead, hPipeWrite]() { char buf[4096]; memset(buf, 0, sizeof buf); for (; !finish_flag ;) @@ -175,7 +177,8 @@ std::shared_ptr OsProcess::asyncExecCommand(const std::string& cmdl } CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); - + if (finished_callback) + finished_callback(std::string()); }); return r; diff --git a/src/engine/helper/HL_Sync.cpp b/src/engine/helper/HL_Sync.cpp index 522e0421..5e833d78 100644 --- a/src/engine/helper/HL_Sync.cpp +++ b/src/engine/helper/HL_Sync.cpp @@ -52,6 +52,16 @@ void ThreadHelper::setName(const std::string &name) #endif } +uint64_t ThreadHelper::getCurrentId() +{ +#if defined(TARGET_WIN) + return static_cast(GetCurrentThreadId()); +#endif + +#if defined(TARGET_LINUX)||defined(TARGET_OSX) + return static_cast(pthread_self()); +#endif +} // ------------------- TimeHelper --------------- using namespace std::chrono; diff --git a/src/engine/helper/HL_Sync.h b/src/engine/helper/HL_Sync.h index f99ccb7c..d301c387 100644 --- a/src/engine/helper/HL_Sync.h +++ b/src/engine/helper/HL_Sync.h @@ -42,6 +42,7 @@ class ThreadHelper { public: static void setName(const std::string& name); + static uint64_t getCurrentId(); }; class TimeHelper