From 40f3d19af6be7a4532e9ea40c2f00112879d3ba1 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Sat, 7 Oct 2023 17:33:18 +0800 Subject: [PATCH] Remove dependent for vcpkg::sdl2 --- application/remote_desk/xmake.lua | 6 ++---- src/ice/ice_agent.cpp | 23 ++++++++++++++++++++++- src/transmission/ice_transmission.cpp | 2 +- thirdparty/libjuice/src/agent.h | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/application/remote_desk/xmake.lua b/application/remote_desk/xmake.lua index 62f7eae..15005e0 100644 --- a/application/remote_desk/xmake.lua +++ b/application/remote_desk/xmake.lua @@ -13,7 +13,6 @@ add_requires("sdl2", {system = false}) if is_os("windows") then add_ldflags("/SUBSYSTEM:CONSOLE") add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32") - add_requires("vcpkg::sdl2 2.26.4") add_requires("vcpkg::ffmpeg 5.1.2", {configs = {shared = false}}) elseif is_os("linux") then add_requires("ffmpeg 5.1.2", {system = false}) @@ -21,7 +20,6 @@ elseif is_os("linux") then add_syslinks("pthread", "dl") elseif is_os("macosx") then add_requires("ffmpeg 5.1.2", {system = false}) - -- add_requires("vcpkg::sdl2 2.28.3", {system = false}) end add_packages("spdlog") @@ -42,7 +40,7 @@ target("screen_capture") target("remote_desk_server") set_kind("binary") - add_packages("log", "vcpkg::ffmpeg", "vcpkg::sdl2") + add_packages("log", "vcpkg::ffmpeg", "sdl2") add_deps("projectx", "screen_capture") add_files("remote_desk_server/*.cpp") add_includedirs("../../src/interface") @@ -59,7 +57,7 @@ target("remote_desk_client") add_deps("projectx") add_packages("log") if is_os("windows") then - add_packages("vcpkg::sdl2") + add_packages("sdl2") elseif is_os("macosx") or is_os("linux")then add_packages("sdl2") add_packages("ffmpeg") diff --git a/src/ice/ice_agent.cpp b/src/ice/ice_agent.cpp index 9402e10..213024f 100644 --- a/src/ice/ice_agent.cpp +++ b/src/ice/ice_agent.cpp @@ -22,7 +22,25 @@ int IceAgent::CreateIceAgent(juice_cb_state_changed_t on_state_changed, juice_cb_candidate_t on_candidate, juice_cb_gathering_done_t on_gathering_done, juice_cb_recv_t on_recv, void *user_ptr) { - // juice_set_log_level(JUICE_LOG_LEVEL_DEBUG); + juice_set_log_level(JUICE_LOG_LEVEL_DEBUG); + + juice_set_log_handler([](juice_log_level_t level, const char *message) { + if (JUICE_LOG_LEVEL_VERBOSE == level) { + LOG_INFO("{}", message); + } else if (JUICE_LOG_LEVEL_DEBUG == level) { + LOG_INFO("{}", message); + } else if (JUICE_LOG_LEVEL_INFO == level) { + LOG_INFO("{}", message); + } else if (JUICE_LOG_LEVEL_WARN == level) { + LOG_WARN("{}", message); + } else if (JUICE_LOG_LEVEL_ERROR == level) { + LOG_ERROR("{}", message); + } else if (JUICE_LOG_LEVEL_FATAL == level) { + LOG_FATAL("{}", message); + } else if (JUICE_LOG_LEVEL_NONE == level) { + LOG_INFO("{}", message); + } + }); juice_config_t config; memset(&config, 0, sizeof(config)); @@ -49,6 +67,9 @@ int IceAgent::CreateIceAgent(juice_cb_state_changed_t on_state_changed, config.cb_recv = on_recv; config.user_ptr = user_ptr; + // config.local_port_range_begin = 40000; + // config.local_port_range_end = 50000; + agent_ = juice_create(&config); return 0; diff --git a/src/transmission/ice_transmission.cpp b/src/transmission/ice_transmission.cpp index 5341712..8aa90dc 100644 --- a/src/transmission/ice_transmission.cpp +++ b/src/transmission/ice_transmission.cpp @@ -133,7 +133,7 @@ int IceTransmission::InitIceTransmission(std::string &stun_ip, int stun_port, } }, [](juice_agent_t *agent, const char *sdp, void *user_ptr) { - // LOG_INFO("candadite: {}", sdp); + LOG_INFO("candadite: {}", sdp); // trickle // static_cast(user_ptr)->SendOfferLocalCandidate(sdp); diff --git a/thirdparty/libjuice/src/agent.h b/thirdparty/libjuice/src/agent.h index 65bb0ca..71e1b06 100644 --- a/thirdparty/libjuice/src/agent.h +++ b/thirdparty/libjuice/src/agent.h @@ -24,6 +24,7 @@ // RFC 8445: Agents MUST NOT use an RTO value smaller than 500 ms. #define MIN_STUN_RETRANSMISSION_TIMEOUT 500 // msecs #define MAX_STUN_RETRANSMISSION_COUNT 5 // count (exponential backoff, will give ~30s) +// #define MAX_STUN_RETRANSMISSION_COUNT 2 // count (exponential backoff, will give ~30s) // RFC 8445: ICE agents SHOULD use a default Ta value, 50 ms, but MAY use // another value based on the characteristics of the associated data.