diff --git a/src/main.cpp b/src/main.cpp index 32485e9c0..17750f345 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1215,13 +1215,22 @@ static int adjust_params(struct ug_options *opt) { punch_c.host_addr = punched_host; punch_c.host_addr_len = sizeof(punched_host); - if(!punch_udp(punch_c)){ + auto punch_fcn = reinterpret_cast( + const_cast( + load_library("udp_holepunch", LIBRARY_CLASS_UNDEFINED, HOLEPUNCH_ABI_VERSION))); + + if(!punch_fcn){ + log_msg(LOG_LEVEL_ERROR, "Failed to load holepunching module\n"); + return EXIT_FAILURE; + } + + if(!punch_fcn(punch_c)){ log_msg(LOG_LEVEL_ERROR, "Hole punching failed.\n"); return EXIT_FAILURE; } log_msg(LOG_LEVEL_INFO, "[holepunch] remote: %s\n rx: %d\n tx: %d\n", - punched_host, opt->video_rx_port, opt->video_tx_port); + punched_host, opt->video_rx_port, opt->video_tx_port); opt->requested_receiver = punched_host; opt->audio.host = punched_host; #endif //HAVE_LIBJUICE diff --git a/src/utils/udp_holepunch.c b/src/utils/udp_holepunch.c index a3e55ca74..200dfd25b 100644 --- a/src/utils/udp_holepunch.c +++ b/src/utils/udp_holepunch.c @@ -35,6 +35,12 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#include "config_unix.h" +#include "config_win32.h" +#endif + #include #include #include @@ -47,6 +53,7 @@ #include "utils/udp_holepunch.h" #include "debug.h" +#include "lib_common.h" #ifdef _WIN32 #include @@ -382,3 +389,5 @@ bool punch_udp(struct Holepunch_config c){ return true; } + +REGISTER_MODULE(udp_holepunch, punch_udp, LIBRARY_CLASS_UNDEFINED, HOLEPUNCH_ABI_VERSION); diff --git a/src/utils/udp_holepunch.h b/src/utils/udp_holepunch.h index 8d3ad4c7a..764536df0 100644 --- a/src/utils/udp_holepunch.h +++ b/src/utils/udp_holepunch.h @@ -46,6 +46,8 @@ extern "C" { #endif +#define HOLEPUNCH_ABI_VERSION 1 + struct Holepunch_config{ const char *client_name; const char *room_name;