From ad3be1650c1bec7c59cbf470a22d1149b7e80e7e Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Wed, 18 Oct 2023 15:12:28 -0400 Subject: [PATCH] misc: windows: remove UWP/store files and code Change-Id: I4875e4d76f5da442eace0204052d536c65545d3f --- .gitignore | 2 +- CMakeLists.txt | 3 - compat/msvc/dlfcn.c | 10 - src/CMakeLists.txt | 3 - src/client/ring_signal.cpp | 2 +- src/client/videomanager.cpp | 8 +- src/connectivity/ip_utils.cpp | 2 +- src/fileutils.cpp | 70 ++---- src/jami/configurationmanager_interface.h | 8 +- src/jami/videomanager_interface.h | 12 +- src/manager.cpp | 69 +++--- src/media/libav_utils.cpp | 36 +-- src/media/video/CMakeLists.txt | 5 - src/media/video/uwpvideo/CMakeLists.txt | 9 - .../video/uwpvideo/video_device_impl.cpp | 216 ------------------ .../uwpvideo/video_device_monitor_impl.cpp | 95 -------- src/media/video/video_input.cpp | 7 +- src/sip/sipaccount.cpp | 21 +- src/winsyslog.c | 6 - test/agent/src/bindings/signal.cpp | 25 +- 20 files changed, 108 insertions(+), 501 deletions(-) delete mode 100644 src/media/video/uwpvideo/CMakeLists.txt delete mode 100644 src/media/video/uwpvideo/video_device_impl.cpp delete mode 100644 src/media/video/uwpvideo/video_device_monitor_impl.cpp diff --git a/.gitignore b/.gitignore index 69fa26ba41..1f3532b366 100644 --- a/.gitignore +++ b/.gitignore @@ -111,7 +111,7 @@ build-macos* /extras/tools/check_sed /extras/tools/libtool-*.tar.xz -# UWP +# Windows native build /contrib/build/ /contrib/msvc/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 66f8d33f32..759b5b587d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,9 +158,6 @@ source_group("Source Files\\media\\video" FILES ${Source_Files__media__video}) source_group("Source Files\\plugin" FILES ${Source_Files__plugin}) if(MSVC) - if(WINDOWS_STORE) - source_group("Source Files\\media\\video\\uwpvideo" FILES ${Source_Files__media__video__uwpvideo}) - endif() source_group("Source Files\\media\\audio\\portaudio" FILES ${Source_Files__media__audio__portaudio}) source_group("Source Files\\media\\video\\winvideo" FILES ${Source_Files__media__video__winvideo}) endif() diff --git a/compat/msvc/dlfcn.c b/compat/msvc/dlfcn.c index 5493c5f0c5..cfbbf596c3 100644 --- a/compat/msvc/dlfcn.c +++ b/compat/msvc/dlfcn.c @@ -136,9 +136,7 @@ void *dlopen( const char *file, int mode ) UINT uMode; current_error = NULL; /* Do not let Windows display the critical-error-handler message box */ -#ifndef RING_UWP uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); -#endif if( file == 0 ) { /* POSIX says that if the value of file is 0, a handle on a global @@ -149,9 +147,7 @@ void *dlopen( const char *file, int mode ) * symbols only from the original program file. For objects loaded with * the RTLD_GLOBAL flag, we create our own list later on. */ -#ifndef RING_UWP hModule = GetModuleHandle( NULL ); -#endif if( !hModule ) save_err_ptr_str( file ); } @@ -175,10 +171,8 @@ else * to UNIX's search paths (start with system folders instead of current * folder). */ -#ifndef RING_UWP hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); -#endif /* If the object was loaded with RTLD_GLOBAL, add it to list of global * objects, so that its symbols may be retrieved even if the handle for * the original program file is passed. POSIX says that if the same @@ -192,9 +186,7 @@ else if( (mode & RTLD_GLOBAL) ) global_add( hModule ); } /* Return to previous state of the error-mode bit flags. */ -#ifndef RING_UWP SetErrorMode( uMode ); -#endif return (void *) hModule; } int dlclose( void *handle ) @@ -225,9 +217,7 @@ void *dlsym( void *handle, const char *name ) /* If the handle for the original program file is passed, also search * in all globally loaded objects. */ -#ifndef RING_UWP hModule = GetModuleHandle( NULL ); -#endif if( hModule == handle ) { global_object *pobject; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c4a7e19d3..7c43ca7890 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -94,9 +94,6 @@ set (Source_Files__media__audio__audio_processing ${Source_Files__media__audio__ set (Source_Files__media__audio__webrtc ${Source_Files__media__audio__webrtc} PARENT_SCOPE) set (Source_Files__media__video ${Source_Files__media__video} PARENT_SCOPE) if(MSVC) - if(WINDOWS_STORE) - set (Source_Files__media__video__uwpvideo ${Source_Files__media__video__uwpvideo} PARENT_SCOPE) - endif() set (Source_Files__media__audio__portaudio ${Source_Files__media__audio__portaudio} PARENT_SCOPE) set (Source_Files__media__video__winvideo ${Source_Files__media__video__winvideo} PARENT_SCOPE) endif() diff --git a/src/client/ring_signal.cpp b/src/client/ring_signal.cpp index cb7bbe1d11..5576d32b3d 100644 --- a/src/client/ring_signal.cpp +++ b/src/client/ring_signal.cpp @@ -85,7 +85,7 @@ getSignalHandlers() #if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) exported_callback<libjami::ConfigurationSignal::GetHardwareAudioFormat>(), #endif -#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) || defined(RING_UWP) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) exported_callback<libjami::ConfigurationSignal::GetAppDataPath>(), exported_callback<libjami::ConfigurationSignal::GetDeviceName>(), #endif diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index a3105cf2d5..224cc7525c 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -142,7 +142,8 @@ AudioFrame::mix(const AudioFrame& frame) { auto& f = *pointer(); auto& fIn = *frame.pointer(); - if (f.ch_layout.nb_channels != fIn.ch_layout.nb_channels || f.format != fIn.format || f.sample_rate != fIn.sample_rate) { + if (f.ch_layout.nb_channels != fIn.ch_layout.nb_channels || f.format != fIn.format + || f.sample_rate != fIn.sample_rate) { throw std::invalid_argument("Can't mix frames with different formats"); } if (f.nb_samples == 0) { @@ -185,7 +186,8 @@ AudioFrame::calcRMS() const double rms = 0.0; auto fmt = static_cast<AVSampleFormat>(frame_->format); bool planar = av_sample_fmt_is_planar(fmt); - int perChannel = planar ? frame_->nb_samples : frame_->nb_samples * frame_->ch_layout.nb_channels; + int perChannel = planar ? frame_->nb_samples + : frame_->nb_samples * frame_->ch_layout.nb_channels; int channels = planar ? frame_->ch_layout.nb_channels : 1; if (fmt == AV_SAMPLE_FMT_S16 || fmt == AV_SAMPLE_FMT_S16P) { for (int c = 0; c < channels; ++c) { @@ -649,7 +651,7 @@ setEncodingAccelerated(bool state) } } -#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) void addVideoDevice(const std::string& node, const std::vector<std::map<std::string, std::string>>& devInfo) diff --git a/src/connectivity/ip_utils.cpp b/src/connectivity/ip_utils.cpp index 73a5257677..c2caed7d33 100644 --- a/src/connectivity/ip_utils.cpp +++ b/src/connectivity/ip_utils.cpp @@ -20,7 +20,7 @@ #include "ip_utils.h" -#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) #define JAMI_DEVICE_SIGNAL 1 #endif diff --git a/src/fileutils.cpp b/src/fileutils.cpp index 3d87a7942b..3743e43f13 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -24,11 +24,6 @@ #include "compiler_intrinsics.h" #include <opendht/crypto.h> -#ifdef RING_UWP -#include <io.h> // for access and close -#include "ring_signal.h" -#endif - #ifdef __APPLE__ #include <TargetConditionals.h> #endif @@ -265,7 +260,10 @@ loadTextFile(const std::filesystem::path& path, const std::filesystem::path& def } void -saveFile(const std::filesystem::path& path, const uint8_t* data, size_t data_size, mode_t UNUSED mode) +saveFile(const std::filesystem::path& path, + const uint8_t* data, + size_t data_size, + mode_t UNUSED mode) { std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { @@ -276,8 +274,7 @@ saveFile(const std::filesystem::path& path, const uint8_t* data, size_t data_siz #ifndef _WIN32 file.close(); if (chmod(path.c_str(), mode) < 0) - JAMI_WARNING("fileutils::saveFile(): chmod() failed on {}, {}", - path, strerror(errno)); + JAMI_WARNING("fileutils::saveFile(): chmod() failed on {}, {}", path, strerror(errno)); #endif } @@ -382,7 +379,7 @@ writeArchive(const std::string& archive_str, const std::string& path, const std: } } -#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) #else static char* program_dir = NULL; void @@ -399,21 +396,7 @@ set_program_dir(char* program_path) std::filesystem::path get_cache_dir(const char* pkg) { -#ifdef RING_UWP - std::string cache_path; - std::vector<std::string> paths; - paths.reserve(1); - emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths); - if (not paths.empty()) { - cache_path = paths[0] + DIR_SEPARATOR_STR + std::string(".cache"); - if (fileutils::recursive_mkdir(cache_path.data(), 0700) != true) { - // If directory creation failed - if (errno != EEXIST) - JAMI_DBG("Cannot create directory: %s!", cache_path.c_str()); - } - } - return cache_path; -#elif defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) std::vector<std::string> paths; paths.reserve(1); emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("cache", &paths); @@ -452,13 +435,6 @@ get_home_dir() if (not paths.empty()) return paths[0]; return {}; -#elif defined RING_UWP - std::vector<std::string> paths; - paths.reserve(1); - emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths); - if (not paths.empty()) - return paths[0]; - return {}; #elif defined _WIN32 TCHAR path[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PROFILE, nullptr, 0, path))) { @@ -507,20 +483,6 @@ get_data_dir(const char* pkg) } else { return get_home_dir() / "AppData" / "Local" / pkg; } -#elif defined(RING_UWP) - std::vector<std::string> paths; - paths.reserve(1); - emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths); - if (not paths.empty()) { - auto files_path = std::filesystem::path(paths[0]) / ".data"; - if (fileutils::recursive_mkdir(files_path.data(), 0700) != true) { - // If directory creation failed - if (errno != EEXIST) - JAMI_DBG("Cannot create directory: %s!", files_path.c_str()); - } - return files_path; - } - return {}; #else std::string_view data_home(XDG_DATA_HOME); if (not data_home.empty()) @@ -546,11 +508,6 @@ get_config_dir(const char* pkg) emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("config", &paths); if (not paths.empty()) configdir = std::filesystem::path(paths[0]); -#elif defined(RING_UWP) - std::vector<std::string> paths; - emitSignal<libjami::ConfigurationSignal::GetAppDataPath>("", &paths); - if (not paths.empty()) - configdir = std::filesystem::path(paths[0]) / ".config"; #elif defined(__APPLE__) configdir = fileutils::get_home_dir() / "Library" / "Application Support" / pkg; #elif defined(_WIN32) @@ -587,8 +544,9 @@ get_config_dir() bool eraseFile_win32(const std::string& path, bool dosync) { - // Note: from https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea#remarks - // To delete a read-only file, first you must remove the read-only attribute. + // Note: from + // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea#remarks To + // delete a read-only file, first you must remove the read-only attribute. SetFileAttributesA(path.c_str(), GetFileAttributesA(path.c_str()) & ~FILE_ATTRIBUTE_READONLY); HANDLE h = CreateFileA(path.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); @@ -656,7 +614,7 @@ eraseFile_posix(const std::string& path, bool dosync) return false; } // Remove read-only flag if possible - chmod(path.c_str(), st.st_mode | (S_IWGRP+S_IWUSR) ); + chmod(path.c_str(), st.st_mode | (S_IWGRP + S_IWUSR)); int fd = open(path.c_str(), O_WRONLY); if (fd == -1) { @@ -693,7 +651,7 @@ eraseFile_posix(const std::string& path, bool dosync) bool eraseFile(const std::string& path, bool dosync) -{ +{ #ifdef _WIN32 return eraseFile_win32(path, dosync); #else @@ -788,8 +746,8 @@ uint64_t lastWriteTimeInSeconds(const std::filesystem::path& filePath) { return std::chrono::duration_cast<std::chrono::seconds>( - std::filesystem::last_write_time(filePath) - .time_since_epoch()).count(); + std::filesystem::last_write_time(filePath).time_since_epoch()) + .count(); } } // namespace fileutils diff --git a/src/jami/configurationmanager_interface.h b/src/jami/configurationmanager_interface.h index f38a1e7e11..a4580eb887 100644 --- a/src/jami/configurationmanager_interface.h +++ b/src/jami/configurationmanager_interface.h @@ -65,8 +65,10 @@ LIBJAMI_PUBLIC std::map<std::string, std::string> getAccountTemplate(const std:: LIBJAMI_PUBLIC std::string addAccount(const std::map<std::string, std::string>& details, const std::string& accountID = {}); LIBJAMI_PUBLIC void monitor(bool continuous); -LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConnectionList(const std::string& accountId, const std::string& conversationId); -LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getChannelList(const std::string& accountId, const std::string& connectionId); +LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConnectionList( + const std::string& accountId, const std::string& conversationId); +LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getChannelList( + const std::string& accountId, const std::string& connectionId); LIBJAMI_PUBLIC bool exportOnRing(const std::string& accountID, const std::string& password); LIBJAMI_PUBLIC bool exportToFile(const std::string& accountID, @@ -537,7 +539,7 @@ struct LIBJAMI_PUBLIC ConfigurationSignal using cb_type = void(std::vector<int32_t>* /* params_ret */); }; #endif -#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) struct LIBJAMI_PUBLIC GetAppDataPath { constexpr static const char* name = "GetAppDataPath"; diff --git a/src/jami/videomanager_interface.h b/src/jami/videomanager_interface.h index 258ad5feaa..0e5bd77b6c 100644 --- a/src/jami/videomanager_interface.h +++ b/src/jami/videomanager_interface.h @@ -57,13 +57,15 @@ namespace libjami { [[deprecated("Replaced by registerSignalHandlers")]] LIBJAMI_PUBLIC void registerVideoHandlers( const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); -struct LIBJAMI_PUBLIC AVFrame_deleter { +struct LIBJAMI_PUBLIC AVFrame_deleter +{ void operator()(AVFrame* frame) const { av_frame_free(&frame); } }; typedef std::unique_ptr<AVFrame, AVFrame_deleter> FrameBuffer; -struct LIBJAMI_PUBLIC AVPacket_deleter { +struct LIBJAMI_PUBLIC AVPacket_deleter +{ void operator()(AVPacket* pkt) const { av_packet_free(&pkt); } }; @@ -184,7 +186,7 @@ LIBJAMI_PUBLIC std::vector<std::string> getDeviceList(); LIBJAMI_PUBLIC VideoCapabilities getCapabilities(const std::string& deviceId); LIBJAMI_PUBLIC std::map<std::string, std::string> getSettings(const std::string& deviceId); LIBJAMI_PUBLIC void applySettings(const std::string& deviceId, - const std::map<std::string, std::string>& settings); + const std::map<std::string, std::string>& settings); LIBJAMI_PUBLIC void setDefaultDevice(const std::string& deviceId); LIBJAMI_PUBLIC void setDeviceOrientation(const std::string& deviceId, int angle); LIBJAMI_PUBLIC std::map<std::string, std::string> getDeviceParams(const std::string& deviceId); @@ -209,10 +211,10 @@ LIBJAMI_PUBLIC void startShmSink(const std::string& sinkId, bool value); LIBJAMI_PUBLIC std::map<std::string, std::string> getRenderer(const std::string& callId); LIBJAMI_PUBLIC std::string startLocalMediaRecorder(const std::string& videoInputId, - const std::string& filepath); + const std::string& filepath); LIBJAMI_PUBLIC void stopLocalRecorder(const std::string& filepath); -#if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) LIBJAMI_PUBLIC void addVideoDevice( const std::string& node, const std::vector<std::map<std::string, std::string>>& devInfo = {}); LIBJAMI_PUBLIC void removeVideoDevice(const std::string& node); diff --git a/src/manager.cpp b/src/manager.cpp index c9f83321d4..cb68e88e94 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -185,7 +185,8 @@ check_rename(const std::filesystem::path& old_dir, const std::filesystem::path& for (const auto& file : dhtnet::fileutils::readDirectory(old_dir)) { auto old_dest = fileutils::getFullPath(old_dir, file); auto new_dest = fileutils::getFullPath(new_dir, file); - if (std::filesystem::is_directory(old_dest) and std::filesystem::is_directory(new_dest)) { + if (std::filesystem::is_directory(old_dest) + and std::filesystem::is_directory(new_dest)) { check_rename(old_dest, new_dest); } else { JAMI_WARNING("Migrating {} to {}", old_dir, new_dest); @@ -210,7 +211,6 @@ static constexpr const char* DHTLOGLEVEL = "DHTLOGLEVEL"; static void setDhtLogLevel() { -#ifndef RING_UWP int level = 0; if (auto envvar = getenv(DHTLOGLEVEL)) { level = to_int<int>(envvar, 0); @@ -218,9 +218,6 @@ setDhtLogLevel() JAMI_DBG("DHTLOGLEVEL=%u", level); } Manager::instance().dhtLogLevel = level; -#else - Manager::instance().dhtLogLevel = 0; -#endif } /** @@ -235,7 +232,6 @@ static constexpr const char* SIPLOGLEVEL = "SIPLOGLEVEL"; static void setSipLogLevel() { -#ifndef RING_UWP char* envvar = getenv(SIPLOGLEVEL); int level = 0; @@ -246,9 +242,6 @@ setSipLogLevel() // From 0 (min) to 6 (max) level = std::max(0, std::min(level, 6)); } -#else - int level = 0; -#endif pj_log_set_level(level); pj_log_set_log_func([](int level, const char* data, int /*len*/) { @@ -278,7 +271,6 @@ tls_print_logs(int level, const char* msg) static void setGnuTlsLogLevel() { -#ifndef RING_UWP char* envvar = getenv("RING_TLS_LOGLEVEL"); int level = RING_TLS_LOGLEVEL; @@ -290,9 +282,6 @@ setGnuTlsLogLevel() } gnutls_global_set_log_level(level); -#else - gnutls_global_set_log_level(RING_TLS_LOGLEVEL); -#endif gnutls_global_set_log_function(tls_print_logs); } @@ -855,7 +844,9 @@ Manager::init(const std::filesystem::path& config_file, libjami::InitFlag flags) if (pimpl_->audiodriver_) { auto format = pimpl_->audiodriver_->getFormat(); pimpl_->toneCtrl_.setSampleRate(format.sample_rate, format.sampleFormat); - pimpl_->dtmfKey_.reset(new DTMF(getRingBufferPool().getInternalSamplingRate(), getRingBufferPool().getInternalAudioFormat().sampleFormat)); + pimpl_->dtmfKey_.reset( + new DTMF(getRingBufferPool().getInternalSamplingRate(), + getRingBufferPool().getInternalAudioFormat().sampleFormat)); } } registerAccounts(); @@ -949,7 +940,8 @@ Manager::monitor(bool continuous) #ifdef __linux__ #if defined(__ANDROID__) #else - auto opened_files = dhtnet::fileutils::readDirectory("/proc/" + std::to_string(getpid()) + "/fd").size(); + auto opened_files + = dhtnet::fileutils::readDirectory("/proc/" + std::to_string(getpid()) + "/fd").size(); JAMI_DBG("Opened files: %lu", opened_files); #endif #endif @@ -1013,9 +1005,10 @@ Manager::getChannelList(const std::string& accountId, const std::string& connect auto account = getAccount(accountId); if (account) { if (auto acc = std::dynamic_pointer_cast<JamiAccount>(account)) { - if (acc->getRegistrationState() != RegistrationState::INITIALIZING){ + if (acc->getRegistrationState() != RegistrationState::INITIALIZING) { const auto& cnl = acc->getChannelList(connectionId); - channelsList.insert(channelsList.end(), cnl.begin(), cnl.end());} + channelsList.insert(channelsList.end(), cnl.begin(), cnl.end()); + } } } } @@ -2567,7 +2560,7 @@ Manager::ManagerPimpl::processIncomingCall(const std::string& accountId, Call& i if (not base_.hasCurrentCall()) { incomCall.setState(Call::ConnectionState::RINGING); -#if !defined(RING_UWP) && !(defined(TARGET_OS_IOS) && TARGET_OS_IOS) +#if !(defined(TARGET_OS_IOS) && TARGET_OS_IOS) if (not account->isRendezVous()) base_.playRingtone(accountId); #endif @@ -2661,9 +2654,7 @@ Manager::audioFormatUsed(AudioFormat format) if (currentFormat == format) return format; - JAMI_DEBUG("Audio format changed: {} -> {}", - currentFormat.toString(), - format.toString()); + JAMI_DEBUG("Audio format changed: {} -> {}", currentFormat.toString(), format.toString()); pimpl_->ringbufferpool_->setInternalAudioFormat(format); pimpl_->toneCtrl_.setSampleRate(format.sample_rate, format.sampleFormat); @@ -2886,28 +2877,24 @@ Manager::loadAccountMap(const YAML::Node& node) continue; } remaining++; - dht::ThreadPool::computation().run([this, - dir, - &cv, - &remaining, - &lock, - configFile = accountBaseDir / dir / "config.yml"] { - if (std::filesystem::is_regular_file(configFile)) { - try { - auto configNode = YAML::LoadFile(configFile.string()); - if (auto a = accountFactory.createAccount(JamiAccount::ACCOUNT_TYPE, dir)) { - auto config = a->buildConfig(); - config->unserialize(configNode); - a->setConfig(std::move(config)); + dht::ThreadPool::computation().run( + [this, dir, &cv, &remaining, &lock, configFile = accountBaseDir / dir / "config.yml"] { + if (std::filesystem::is_regular_file(configFile)) { + try { + auto configNode = YAML::LoadFile(configFile.string()); + if (auto a = accountFactory.createAccount(JamiAccount::ACCOUNT_TYPE, dir)) { + auto config = a->buildConfig(); + config->unserialize(configNode); + a->setConfig(std::move(config)); + } + } catch (const std::exception& e) { + JAMI_ERR("Can't import account %s: %s", dir.c_str(), e.what()); } - } catch (const std::exception& e) { - JAMI_ERR("Can't import account %s: %s", dir.c_str(), e.what()); } - } - std::lock_guard<std::mutex> l(lock); - remaining--; - cv.notify_one(); - }); + std::lock_guard<std::mutex> l(lock); + remaining--; + cv.notify_one(); + }); } cv.wait(l, [&remaining] { return remaining == 0; }); diff --git a/src/media/libav_utils.cpp b/src/media/libav_utils.cpp index ea22450986..8cf6da14c4 100644 --- a/src/media/libav_utils.cpp +++ b/src/media/libav_utils.cpp @@ -57,7 +57,10 @@ namespace jami { namespace libav_utils { AVSampleFormat -choose_sample_fmt(const AVCodec *codec, const AVSampleFormat *preferred_formats, int preferred_formats_count) { +choose_sample_fmt(const AVCodec* codec, + const AVSampleFormat* preferred_formats, + int preferred_formats_count) +{ for (int i = 0; i < preferred_formats_count; ++i) { for (auto it = codec->sample_fmts; *it != -1; ++it) { if (*it == preferred_formats[i]) @@ -68,20 +71,21 @@ choose_sample_fmt(const AVCodec *codec, const AVSampleFormat *preferred_formats, } AVSampleFormat -choose_sample_fmt_default(const AVCodec* codec, AVSampleFormat defaultFormat) { +choose_sample_fmt_default(const AVCodec* codec, AVSampleFormat defaultFormat) +{ // List of supported formats, current default first - const AVSampleFormat preferred_formats[] = { - defaultFormat, - AV_SAMPLE_FMT_FLTP, - AV_SAMPLE_FMT_FLT, - AV_SAMPLE_FMT_S16P, - AV_SAMPLE_FMT_S16, - AV_SAMPLE_FMT_DBLP, - AV_SAMPLE_FMT_DBL, - AV_SAMPLE_FMT_S32P, - AV_SAMPLE_FMT_S32 - }; - return choose_sample_fmt(codec, preferred_formats, sizeof(preferred_formats) / sizeof(preferred_formats[0])); + const AVSampleFormat preferred_formats[] = {defaultFormat, + AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_FLT, + AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_S16, + AV_SAMPLE_FMT_DBLP, + AV_SAMPLE_FMT_DBL, + AV_SAMPLE_FMT_S32P, + AV_SAMPLE_FMT_S32}; + return choose_sample_fmt(codec, + preferred_formats, + sizeof(preferred_formats) / sizeof(preferred_formats[0])); } #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) @@ -125,7 +129,6 @@ static constexpr const char* AVLOGLEVEL = "AVLOGLEVEL"; static void setAvLogLevel() { -#ifndef RING_UWP char* envvar = getenv(AVLOGLEVEL); signed level = AV_LOG_WARNING; @@ -134,9 +137,6 @@ setAvLogLevel() level = std::max(AV_LOG_QUIET, std::min(level, AV_LOG_DEBUG)); } av_log_set_level(level); -#else - av_log_set_level(0); -#endif } #ifdef __ANDROID__ diff --git a/src/media/video/CMakeLists.txt b/src/media/video/CMakeLists.txt index 9613930162..441b29da08 100644 --- a/src/media/video/CMakeLists.txt +++ b/src/media/video/CMakeLists.txt @@ -34,11 +34,6 @@ list (APPEND Source_Files__media__video set (Source_Files__media__video ${Source_Files__media__video} PARENT_SCOPE) if(MSVC) - if(WINDOWS_STORE) - add_subdirectory(uwpvideo) - set (Source_Files__media__video__uwpvideo ${Source_Files__media__video__uwpvideo} PARENT_SCOPE) - endif() - add_subdirectory(winvideo) set (Source_Files__media__video__winvideo ${Source_Files__media__video__winvideo} PARENT_SCOPE) endif() diff --git a/src/media/video/uwpvideo/CMakeLists.txt b/src/media/video/uwpvideo/CMakeLists.txt deleted file mode 100644 index 6f1dcc7ed0..0000000000 --- a/src/media/video/uwpvideo/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -################################################################################ -# Source groups - uwpvideo -################################################################################ -list (APPEND Source_Files__media__video__uwpvideo - "${CMAKE_CURRENT_SOURCE_DIR}/video_device_impl.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/video_device_monitor_impl.cpp" -) - -set (Source_Files__media__video__uwpvideo ${Source_Files__media__video__uwpvideo} PARENT_SCOPE) diff --git a/src/media/video/uwpvideo/video_device_impl.cpp b/src/media/video/uwpvideo/video_device_impl.cpp deleted file mode 100644 index d41f43252f..0000000000 --- a/src/media/video/uwpvideo/video_device_impl.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com> - * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <array> - -extern "C" { -#include <libavutil/pixfmt.h> -} - -#include "logger.h" -#include "../video_device.h" - -#include "ring_signal.h" - -//#include <ciso646> - -namespace jami { -namespace video { - -typedef struct -{ - std::string name; - enum AVPixelFormat pixfmt; -} uwp_fmt; - -// have all formats map to bgra -static const std::array<uwp_fmt, 4> uwp_formats {uwp_fmt {"MJPG", AV_PIX_FMT_BGRA}, - uwp_fmt {"RGB24", AV_PIX_FMT_BGRA}, - uwp_fmt {"NV12", AV_PIX_FMT_BGRA}, - uwp_fmt {"YUY2", AV_PIX_FMT_BGRA}}; - -class VideoDeviceImpl -{ -public: - VideoDeviceImpl(const std::string& path, - const std::vector<std::map<std::string, std::string>>& devInfo); - - std::string name; - - DeviceParams getDeviceParams() const; - - void setDeviceParams(const DeviceParams&); - void selectFormat(); - - std::vector<VideoSize> getSizeList() const; - std::vector<FrameRate> getRateList() const; - -private: - VideoSize getSize(VideoSize size) const; - FrameRate getRate(FrameRate rate) const; - - std::vector<std::string> formats_ {}; - std::vector<VideoSize> sizes_ {}; - std::vector<FrameRate> rates_ {}; - - const uwp_fmt* fmt_ {nullptr}; - VideoSize size_ {}; - FrameRate rate_ {}; -}; - -void -VideoDeviceImpl::selectFormat() -{ - unsigned best = UINT_MAX; - for (auto fmt : formats_) { - auto f = uwp_formats.begin(); - for (; f != uwp_formats.end(); ++f) { - if (f->name == fmt) { - auto pos = std::distance(uwp_formats.begin(), f); - if (pos < best) - best = pos; - break; - } - } - if (f == uwp_formats.end()) - JAMI_WARN("Video: No format matching %s", fmt.c_str()); - } - - if (best != UINT_MAX) { - fmt_ = &uwp_formats[best]; - JAMI_DBG("Video: picked format %s", fmt_->name.c_str()); - } else { - fmt_ = &uwp_formats[0]; - JAMI_ERR("Video: Could not find a known format to use"); - } -} - -VideoDeviceImpl::VideoDeviceImpl(const std::string& path, - const std::vector<std::map<std::string, std::string>>& devInfo) - : name(path) -{ - for (auto& setting : devInfo) { - formats_.emplace_back(setting.at("format")); - sizes_.emplace_back(std::stoi(setting.at("width")), std::stoi(setting.at("height"))); - rates_.emplace_back(std::stoi(setting.at("rate")), 1); - } - selectFormat(); -} - -VideoSize -VideoDeviceImpl::getSize(VideoSize size) const -{ - for (const auto& iter : sizes_) { - if (iter == size) - return iter; - } - - return sizes_.empty() ? VideoSize {0, 0} : sizes_.back(); -} - -FrameRate -VideoDeviceImpl::getRate(FrameRate rate) const -{ - for (const auto& iter : rates_) { - if (iter == rate) - return iter; - } - - return rates_.empty() ? FrameRate {0, 0} : rates_.back(); -} - -std::vector<VideoSize> -VideoDeviceImpl::getSizeList() const -{ - return sizes_; -} - -std::vector<FrameRate> -VideoDeviceImpl::getRateList() const -{ - return rates_; -} - -DeviceParams -VideoDeviceImpl::getDeviceParams() const -{ - DeviceParams params; - params.format = std::to_string(fmt_->pixfmt); - params.name = name; - params.input = name; - params.channel = 0; - params.width = size_.first; - params.height = size_.second; - params.framerate = rate_; - - return params; -} - -void -VideoDeviceImpl::setDeviceParams(const DeviceParams& params) -{ - size_ = getSize({params.width, params.height}); - rate_ = getRate(params.framerate); - emitSignal<libjami::VideoSignal::ParametersChanged>(name); -} - -VideoDevice::VideoDevice(const std::string& path, - const std::vector<std::map<std::string, std::string>>& devInfo) - : deviceImpl_(new VideoDeviceImpl(path, devInfo)) -{ - node_ = path; - name = deviceImpl_->name; -} - -DeviceParams -VideoDevice::getDeviceParams() const -{ - return deviceImpl_->getDeviceParams(); -} - -void -VideoDevice::setDeviceParams(const DeviceParams& params) -{ - return deviceImpl_->setDeviceParams(params); -} - -std::vector<std::string> -VideoDevice::getChannelList() const -{ - return {"default"}; -} - -std::vector<VideoSize> -VideoDevice::getSizeList(const std::string& channel) const -{ - return deviceImpl_->getSizeList(); -} - -std::vector<FrameRate> -VideoDevice::getRateList(const std::string& channel, VideoSize size) const -{ - return deviceImpl_->getRateList(); -} - -VideoDevice::~VideoDevice() {} - -} // namespace video -} // namespace jami diff --git a/src/media/video/uwpvideo/video_device_monitor_impl.cpp b/src/media/video/uwpvideo/video_device_monitor_impl.cpp deleted file mode 100644 index 8b61139b95..0000000000 --- a/src/media/video/uwpvideo/video_device_monitor_impl.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> - * Author: Edric Milaret <edric.ladent-milaret@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <mutex> -#include <thread> - -#include "../video_device_monitor.h" -#include "logger.h" -#include "noncopyable.h" - -namespace jami { -namespace video { - -class VideoDeviceMonitorImpl -{ -public: - /* - * This is the only restriction to the pImpl design: - * as the Linux implementation has a thread, it needs a way to notify - * devices addition and deletion. - * - * This class should maybe inherit from VideoDeviceMonitor instead of - * being its pImpl. - */ - VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor); - ~VideoDeviceMonitorImpl(); - - void start(); - -private: - NON_COPYABLE(VideoDeviceMonitorImpl); - - VideoDeviceMonitor* monitor_; - - void run(); - - mutable std::mutex mutex_; - bool probing_; - std::thread thread_; -}; - -VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor) - : monitor_(monitor) - , mutex_() - , thread_() -{} - -void -VideoDeviceMonitorImpl::start() -{ - probing_ = true; - thread_ = std::thread(&VideoDeviceMonitorImpl::run, this); -} - -VideoDeviceMonitorImpl::~VideoDeviceMonitorImpl() -{ - probing_ = false; - if (thread_.joinable()) - thread_.join(); -} - -void -VideoDeviceMonitorImpl::run() -{} - -VideoDeviceMonitor::VideoDeviceMonitor() - : preferences_() - , devices_() - , monitorImpl_(new VideoDeviceMonitorImpl(this)) -{ - monitorImpl_->start(); -} - -VideoDeviceMonitor::~VideoDeviceMonitor() {} - -} // namespace video -} // namespace jami diff --git a/src/media/video/video_input.cpp b/src/media/video/video_input.cpp index 23937d97d8..8670ca4889 100644 --- a/src/media/video/video_input.cpp +++ b/src/media/video/video_input.cpp @@ -63,7 +63,7 @@ VideoInput::VideoInput(VideoInputMode inputMode, const std::string& id_) { inputMode_ = inputMode; if (inputMode_ == VideoInputMode::Undefined) { -#if (defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)) +#if (defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)) inputMode_ = VideoInputMode::ManagedByClient; #else inputMode_ = VideoInputMode::ManagedByDaemon; @@ -256,8 +256,7 @@ VideoInput::configureFilePlayback(const std::string&, } void -VideoInput::setRecorderCallback( - const std::function<void(const MediaStream& ms)>& cb) +VideoInput::setRecorderCallback(const std::function<void(const MediaStream& ms)>& cb) { recorderCallback_ = cb; if (decoder_) @@ -495,7 +494,7 @@ VideoInput::initWindowsGrab(const std::string& display) DeviceParams p = jami::getVideoDeviceMonitor().getDeviceParams(DEVICE_DESKTOP); if (winHandlePos != std::string::npos) { p.input = display.substr(winHandlePos + windowIdStr.size()); // "HANDLE"; - p.name = display.substr(winHandlePos + windowIdStr.size()); // "HANDLE"; + p.name = display.substr(winHandlePos + windowIdStr.size()); // "HANDLE"; p.is_area = 0; } else { p.input = display.substr(1); diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 96a2498fdf..dce84f1d7e 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -55,7 +55,6 @@ #include "system_codec_container.h" - #include "string_utils.h" #include "im/instant_messaging.h" @@ -193,7 +192,8 @@ SIPAccount::newOutgoingCall(std::string_view toUrl, const std::vector<libjami::M std::shared_ptr<SipTransport> t = isTlsEnabled() ? link_.sipTransportBroker->getTlsTransport(tlsListener_, - dhtnet::IpAddr(sip_utils::getHostFromUri(to))) + dhtnet::IpAddr( + sip_utils::getHostFromUri(to))) : transport_; setTransport(t); call->setSipTransport(t, getContactHeader()); @@ -479,7 +479,9 @@ SIPAccount::getVolatileAccountDetails() const bool SIPAccount::mapPortUPnP() { - dhtnet::upnp::Mapping map(dhtnet::upnp::PortType::UDP, config().publishedPort, config().localPort); + dhtnet::upnp::Mapping map(dhtnet::upnp::PortType::UDP, + config().publishedPort, + config().localPort); map.setNotifyCallback([w = weak()](dhtnet::upnp::Mapping::sharedPtr_t mapRes) { if (auto accPtr = w.lock()) { auto oldPort = static_cast<in_port_t>(accPtr->publishedPortUsed_); @@ -1119,8 +1121,6 @@ SIPAccount::getLoginName() #ifndef _WIN32 struct passwd* user_info = getpwuid(getuid()); return user_info ? user_info->pw_name : ""; -#elif defined(RING_UWP) - return "Unknown"; #else DWORD size = UNLEN + 1; TCHAR username[UNLEN + 1]; @@ -1972,11 +1972,12 @@ SIPAccount::createBindingAddress() auto family = hostIp_ ? hostIp_.getFamily() : PJ_AF_INET; const auto& conf = config(); - dhtnet::IpAddr ret = conf.bindAddress.empty() - ? (conf.interface == dhtnet::ip_utils::DEFAULT_INTERFACE || conf.interface.empty() - ? dhtnet::ip_utils::getAnyHostAddr(family) - : dhtnet::ip_utils::getInterfaceAddr(getLocalInterface(), family)) - : dhtnet::IpAddr(conf.bindAddress, family); + dhtnet::IpAddr ret = conf.bindAddress.empty() ? ( + conf.interface == dhtnet::ip_utils::DEFAULT_INTERFACE + || conf.interface.empty() + ? dhtnet::ip_utils::getAnyHostAddr(family) + : dhtnet::ip_utils::getInterfaceAddr(getLocalInterface(), family)) + : dhtnet::IpAddr(conf.bindAddress, family); if (ret.getPort() == 0) { ret.setPort(conf.tlsEnable ? conf.tlsListenerPort : conf.localPort); diff --git a/src/winsyslog.c b/src/winsyslog.c index 65e8f11cb9..441ca3474c 100644 --- a/src/winsyslog.c +++ b/src/winsyslog.c @@ -65,9 +65,7 @@ getLastErrorText( // converts "Lasr Error" code into text void closelog(void) { -#ifndef RING_UWP DeregisterEventSource(loghdl); -#endif free(loghdr); } @@ -89,7 +87,6 @@ void syslog(int level, const char* format, ...) vsnprintf(tmp, 1024, format, arglist); -#ifndef RING_UWP arr[0] = tmp; BOOL err = ReportEvent(loghdl, (unsigned short) level, (unsigned short)level, level, NULL, 1, 0, arr, NULL); @@ -99,7 +96,6 @@ void syslog(int level, const char* format, ...) CHAR errText[1024]; puts(getLastErrorText(errText, 1024)); } -#endif va_end(arglist); } @@ -116,9 +112,7 @@ void syslog(int level, const char* format, ...) if (loghdl) { closelog(); } -#ifndef RING_UWP loghdl = RegisterEventSource(NULL, ident); -#endif sprintf(tmp, (logopt & WINLOG_PID) ? "%s[%d]" : "%s", ident, getpid()); loghdr = _strdup(tmp); /* save header for later */ } diff --git a/test/agent/src/bindings/signal.cpp b/test/agent/src/bindings/signal.cpp index ed3085f7d7..ec3be0ffb7 100644 --- a/test/agent/src/bindings/signal.cpp +++ b/test/agent/src/bindings/signal.cpp @@ -241,8 +241,8 @@ install_signal_primitives(void*) add_handler<libjami::CallSignal::SmartInfo, const std::map<std::string, std::string>&>(handlers, "smart-info"); - add_handler<libjami::CallSignal::ConnectionUpdate, const std::string&, int>(handlers, - "connection-update"); + add_handler<libjami::CallSignal::ConnectionUpdate, const std::string&, int>( + handlers, "connection-update"); add_handler<libjami::CallSignal::OnConferenceInfosUpdated, const std::string&, @@ -388,7 +388,7 @@ install_signal_primitives(void*) add_handler<libjami::ConfigurationSignal::GetHardwareAudioFormat, std::vector<int32_t>*>(handlers, "get-hardware-audio-format"); #endif -#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) || defined(RING_UWP) +#if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) add_handler<libjami::ConfigurationSignal::GetAppDataPath, const std::string&, std::vector<std::string>*>(handlers, "get-app-data-path"); @@ -403,7 +403,7 @@ install_signal_primitives(void*) bool>(handlers, "hardware-encoding-changed"); add_handler<libjami::ConfigurationSignal::MessageSend, const std::string&>(handlers, - "message-send"); + "message-send"); /* Presence */ add_handler<libjami::PresenceSignal::NewServerSubscriptionRequest, @@ -434,7 +434,8 @@ install_signal_primitives(void*) /* Audio */ add_handler<libjami::AudioSignal::DeviceEvent>(handlers, "audio-device-event"); - add_handler<libjami::AudioSignal::AudioMeter, const std::string&, float>(handlers, "audio-meter"); + add_handler<libjami::AudioSignal::AudioMeter, const std::string&, float>(handlers, + "audio-meter"); /* DataTransfer */ add_handler<libjami::DataTransferSignal::DataTransferEvent, @@ -479,16 +480,17 @@ install_signal_primitives(void*) add_handler<libjami::VideoSignal::RequestKeyFrame>(handlers, "video-request-key-frame"); - add_handler<libjami::VideoSignal::SetBitrate, const std::string&, const int>(handlers, - "video-set-bitrate"); + add_handler<libjami::VideoSignal::SetBitrate, const std::string&, const int>( + handlers, "video-set-bitrate"); #endif add_handler<libjami::VideoSignal::StartCapture, const std::string&>(handlers, - "video-start-capture"); + "video-start-capture"); add_handler<libjami::VideoSignal::StopCapture>(handlers, "video-stop-capture"); - add_handler<libjami::VideoSignal::DeviceAdded, const std::string&>(handlers, "video-device-added"); + add_handler<libjami::VideoSignal::DeviceAdded, const std::string&>(handlers, + "video-device-added"); add_handler<libjami::VideoSignal::ParametersChanged, const std::string&>(handlers, "video-parameters-changed"); @@ -521,8 +523,9 @@ install_signal_primitives(void*) const std::string&, const std::string&>(handlers, "conversation-request-declined"); - add_handler<libjami::ConversationSignal::ConversationReady, const std::string&, const std::string&>( - handlers, "conversation-ready"); + add_handler<libjami::ConversationSignal::ConversationReady, + const std::string&, + const std::string&>(handlers, "conversation-ready"); add_handler<libjami::ConversationSignal::ConversationRemoved, const std::string&, -- GitLab