From d603b188aa98f1890e34973a60d1e1c40fc9079c Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Mon, 28 Dec 2020 16:29:42 +0100 Subject: [PATCH 01/12] FreeBSD support --- README.md | 24 ++++++++++++++++++++++++ configure.ac | 8 ++++++-- janus.c | 1 + plugins/janus_audiobridge.c | 4 ++++ rtcp.h | 2 ++ rtp.h | 2 +- text2pcap.c | 5 +++++ transports/janus_websockets.c | 31 +++++++++++++++++++++---------- 8 files changed, 64 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index eb508ffbff..af56b1fde4 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,30 @@ If Doxygen and graphviz are available, the process can also build the documentat You can also selectively enable/disable other features (e.g., specific plugins you don't care about, or whether or not you want to build the recordings post-processor). Use the --help option when configuring for more info. +### Building on FreeBSD + pkg install libsrtp2 \ + libusrsctp \ + jansson \ + libnice \ + libmicrohttpd \ + libwebsockets \ + curl \ + opus \ + sofia-sip \ + libogg \ + jansson \ + libnice \ + libconfig \ + libtool \ + gmake \ + autoconf \ + autoconf-wrapper \ + glib + + sh autogen.sh + ./configure + gmake + gmake install ### Building on MacOS While most of the above instructions will work when compiling Janus on MacOS as well, there are a few aspects to highlight when doing that. diff --git a/configure.ac b/configure.ac index e29cadd2a3..2c44fc61cd 100644 --- a/configure.ac +++ b/configure.ac @@ -82,6 +82,12 @@ darwin*) LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/opt/local/lib -L/usr/local/libsrtp/lib" AM_CONDITIONAL([DARWIN_OS], true) ;; +freebsd*) + CFLAGS="$CFLAGS -I /usr/include/openssl -I/usr/local/lib/include/nice" + LDFLAGS="$LDFLAGS -Xlinker --export-dynamic" + LDFLAGS="$LDFLAGS -L/usr/lib/openssl -lcrypto -lssl -L/usr/local/lib -lnice" + AM_CONDITIONAL([DARWIN_OS], false) +;; *) LDFLAGS="$LDFLAGS -Wl,--export-dynamic" AM_CONDITIONAL([DARWIN_OS], false) @@ -343,8 +349,6 @@ PKG_CHECK_MODULES([JANUS], libconfig nice jansson >= $jansson_version - libssl >= $ssl_version - libcrypto zlib ]) JANUS_MANUAL_LIBS="${JANUS_MANUAL_LIBS} -lm" diff --git a/janus.c b/janus.c index 144405752f..2d5c20aa4d 100644 --- a/janus.c +++ b/janus.c @@ -5333,6 +5333,7 @@ gint main(int argc, char *argv[]) if (!transport) { JANUS_LOG(LOG_ERR, "\tCouldn't load transport plugin '%s': %s\n", transportent->d_name, dlerror()); } else { + dlerror();//clear errors create_t *create = (create_t*) dlsym(transport, "create"); const char *dlsym_error = dlerror(); if (dlsym_error) { diff --git a/plugins/janus_audiobridge.c b/plugins/janus_audiobridge.c index dc15c7ed05..e286eec8fe 100644 --- a/plugins/janus_audiobridge.c +++ b/plugins/janus_audiobridge.c @@ -857,6 +857,10 @@ room-: { */ #include "plugin.h" +#ifdef __FreeBSD__ +#include +#include +#endif #include #include diff --git a/rtcp.h b/rtcp.h index 95862f5137..f9a3aba7ca 100644 --- a/rtcp.h +++ b/rtcp.h @@ -19,6 +19,8 @@ #include #ifdef __MACH__ #include +#elif defined(__FreeBSD__) +#include #else #include #endif diff --git a/rtp.h b/rtp.h index 92284e779d..97fa1d6c0e 100644 --- a/rtp.h +++ b/rtp.h @@ -14,7 +14,7 @@ #define JANUS_RTP_H #include -#ifdef __MACH__ +#if defined (__MACH__) || defined(__FreeBSD__) #include #define __BYTE_ORDER BYTE_ORDER #define __BIG_ENDIAN BIG_ENDIAN diff --git a/text2pcap.c b/text2pcap.c index 06680c1d0a..4ab04adf91 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -41,6 +41,11 @@ #define __BYTE_ORDER BYTE_ORDER #define __BIG_ENDIAN BIG_ENDIAN #define __LITTLE_ENDIAN LITTLE_ENDIAN +#elif defined(__FreeBSD__) +#include +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +#define __LITTLE_ENDIAN LITTLE_ENDIAN #else #include #endif diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index 49c4f4fa55..8cee1c2fc3 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -293,7 +293,7 @@ static const char *janus_websockets_reason_string(enum lws_callback_reasons reas #if (LWS_LIBRARY_VERSION_MAJOR >= 4) static lws_retry_bo_t pingpong = { 0 }; #endif - +struct in_addr addr; /* Helper method to return the interface associated with a local IP address */ static char *janus_websockets_get_interface_name(const char *ip) { struct ifaddrs *addrs = NULL, *iap = NULL; @@ -591,13 +591,6 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi /* Force single-thread server */ wscinfo.count_threads = 1; - /* Create the base context */ - wsc = lws_create_context(&wscinfo); - if(wsc == NULL) { - JANUS_LOG(LOG_ERR, "Error creating libwebsockets context...\n"); - janus_config_destroy(config); - return -1; /* No point in keeping the plugin loaded */ - } /* Setup the Janus API WebSockets server(s) */ item = janus_config_get(config, config_general, janus_config_type_item, "ws"); @@ -618,12 +611,22 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi item = janus_config_get(config, config_general, janus_config_type_item, "ws_ip"); if(item && item->value) { ip = (char *)item->value; + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + wscinfo.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + } char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); } - ip = iface; + //ip = iface; } + /* Create the base context */ + wsc = lws_create_context(&wscinfo); + if(wsc == NULL) { + JANUS_LOG(LOG_ERR, "Error creating libwebsockets context...\n"); + janus_config_destroy(config); + return -1; /* No point in keeping the plugin loaded */ + } /* Prepare context */ struct lws_context_creation_info info; memset(&info, 0, sizeof info); @@ -656,19 +659,24 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi JANUS_LOG(LOG_ERR, "Invalid port (%s), falling back to default\n", item->value); wsport = 8989; } + int ipv4_only = 0; char *interface = NULL; item = janus_config_get(config, config_general, janus_config_type_item, "wss_interface"); if(item && item->value) interface = (char *)item->value; char *ip = NULL; item = janus_config_get(config, config_general, janus_config_type_item, "wss_ip"); + if(item && item->value) { ip = (char *)item->value; + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + ipv4_only = 1; + } char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); } - ip = iface; + //ip = iface; } item = janus_config_get(config, config_certs, janus_config_type_item, "cert_pem"); if(!item || !item->value) { @@ -706,6 +714,9 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #else info.options = 0; #endif + if(ipv4_only) { + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + } /* Create the secure WebSocket context */ swss = lws_create_vhost(wsc, &info); if(swss == NULL) { From 57e365f20bb025d9327a43bb66ae0dce0aeed8a1 Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Mon, 28 Dec 2020 18:14:55 +0100 Subject: [PATCH 02/12] Try to correct configure.ac for all systems --- configure.ac | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 2c44fc61cd..db141e73e1 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,11 @@ clang*) -Wno-cast-align \ -Wno-initializer-overrides" ;; +cc*) + CFLAGS="$CFLAGS \ + -Wno-cast-align \ + -Wno-initializer-overrides" +;; *) # Specific gcc flags CFLAGS="$CFLAGS \ @@ -68,7 +73,6 @@ clang*) -Wunsafe-loop-optimizations \ -Wunused-but-set-variable" esac - JANUS_VERSION=110 AC_SUBST(JANUS_VERSION) JANUS_VERSION_STRING="0.10.10" @@ -341,16 +345,29 @@ AC_ARG_ENABLE([systemd-sockets], [Enable Systemd Unix Sockets management])], [], [enable_systemd_sockets=no]) - -PKG_CHECK_MODULES([JANUS], - [ - glib-2.0 >= $glib_version +case "$host_os" in +freebsd*) + PKGCHECKMODULES="glib-2.0 >= $glib_version gio-2.0 >= $glib_version libconfig nice jansson >= $jansson_version - zlib - ]) + zlib" +;; +*) + PKGCHECKMODULES="glib-2.0 >= $glib_version + gio-2.0 >= $glib_version + libconfig + nice + jansson >= $jansson_version + libssl >= $ssl_version + libcrypto + zlib" + +esac +PKG_CHECK_MODULES([JANUS],"$PKGCHECKMODULES") + + JANUS_MANUAL_LIBS="${JANUS_MANUAL_LIBS} -lm" AC_SUBST(JANUS_MANUAL_LIBS) From 383fb2aebd411ca357b09f8f9dfcab29d2f8b05e Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Mon, 4 Jan 2021 22:25:58 +0100 Subject: [PATCH 03/12] Do not add libnice explictly Add LWS_SERVER_OPTION_DISABLE_IPV6 only for FreeBSD. --- configure.ac | 4 +- transports/janus_websockets.c | 83 +++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index db141e73e1..8e3778ded4 100644 --- a/configure.ac +++ b/configure.ac @@ -87,9 +87,9 @@ darwin*) AM_CONDITIONAL([DARWIN_OS], true) ;; freebsd*) - CFLAGS="$CFLAGS -I /usr/include/openssl -I/usr/local/lib/include/nice" + CFLAGS="$CFLAGS -I /usr/include/openssl" LDFLAGS="$LDFLAGS -Xlinker --export-dynamic" - LDFLAGS="$LDFLAGS -L/usr/lib/openssl -lcrypto -lssl -L/usr/local/lib -lnice" + LDFLAGS="$LDFLAGS -L/usr/lib/openssl -lcrypto -lssl -L/usr/local/lib" AM_CONDITIONAL([DARWIN_OS], false) ;; *) diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index 8cee1c2fc3..3042e53bbc 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -293,7 +293,7 @@ static const char *janus_websockets_reason_string(enum lws_callback_reasons reas #if (LWS_LIBRARY_VERSION_MAJOR >= 4) static lws_retry_bo_t pingpong = { 0 }; #endif -struct in_addr addr; + /* Helper method to return the interface associated with a local IP address */ static char *janus_websockets_get_interface_name(const char *ip) { struct ifaddrs *addrs = NULL, *iap = NULL; @@ -385,7 +385,9 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #ifndef LWS_WITH_IPV6 JANUS_LOG(LOG_WARN, "libwebsockets has been built without IPv6 support, will bind to IPv4 only\n"); #endif - +#ifdef __FreeBSD__ + int ipv4_only = 0; +#endif /* This is the callback we'll need to invoke to contact the Janus core */ gateway = callback; @@ -590,7 +592,13 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #endif /* Force single-thread server */ wscinfo.count_threads = 1; - + /* Create the base context */ + wsc = lws_create_context(&wscinfo); + if(wsc == NULL) { + JANUS_LOG(LOG_ERR, "Error creating libwebsockets context...\n"); + janus_config_destroy(config); + return -1; /* No point in keeping the plugin loaded */ + } /* Setup the Janus API WebSockets server(s) */ item = janus_config_get(config, config_general, janus_config_type_item, "ws"); @@ -611,22 +619,18 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi item = janus_config_get(config, config_general, janus_config_type_item, "ws_ip"); if(item && item->value) { ip = (char *)item->value; +#ifdef __FreeBSD__ + struct in_addr addr; if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { - wscinfo.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 1; } +#endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); } - //ip = iface; + ip = iface; } - /* Create the base context */ - wsc = lws_create_context(&wscinfo); - if(wsc == NULL) { - JANUS_LOG(LOG_ERR, "Error creating libwebsockets context...\n"); - janus_config_destroy(config); - return -1; /* No point in keeping the plugin loaded */ - } /* Prepare context */ struct lws_context_creation_info info; memset(&info, 0, sizeof info); @@ -640,6 +644,12 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi info.gid = -1; info.uid = -1; info.options = 0; +#ifdef __FreeBSD__ + if (ipv4_only) { + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only=0; + } +#endif /* Create the WebSocket context */ wss = lws_create_vhost(wsc, &info); if(wss == NULL) { @@ -659,7 +669,7 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi JANUS_LOG(LOG_ERR, "Invalid port (%s), falling back to default\n", item->value); wsport = 8989; } - int ipv4_only = 0; + ipv4_only = 0; char *interface = NULL; item = janus_config_get(config, config_general, janus_config_type_item, "wss_interface"); if(item && item->value) @@ -669,14 +679,17 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi if(item && item->value) { ip = (char *)item->value; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { - ipv4_only = 1; +#ifdef __FreeBSD__ + struct in_addr addr; + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + ipv4_only = 1; } +#endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); } - //ip = iface; + ip = iface; } item = janus_config_get(config, config_certs, janus_config_type_item, "cert_pem"); if(!item || !item->value) { @@ -714,9 +727,13 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #else info.options = 0; #endif + +#ifdef __FreeBSD__ if(ipv4_only) { - info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 0; } +#endif /* Create the secure WebSocket context */ swss = lws_create_vhost(wsc, &info); if(swss == NULL) { @@ -745,7 +762,14 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi char *ip = NULL; item = janus_config_get(config, config_admin, janus_config_type_item, "admin_ws_ip"); if(item && item->value) { - ip = (char *)item->value; + ip = (char *)item->value; +#ifdef __FreeBSD__ + struct in_addr addr; + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + ipv4_only = 1; + } +#endif + char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); @@ -765,6 +789,13 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi info.gid = -1; info.uid = -1; info.options = 0; +#ifdef __FreeBSD__ + if (ipv4_only) { + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 0; + } +#endif + /* Create the WebSocket context */ admin_wss = lws_create_vhost(wsc, &info); if(admin_wss == NULL) { @@ -791,7 +822,13 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi char *ip = NULL; item = janus_config_get(config, config_admin, janus_config_type_item, "admin_wss_ip"); if(item && item->value) { - ip = (char *)item->value; + ip = (char *)item->value; +#ifdef __FreeBSD__ + struct in_addr addr; + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + ipv4_only = 1; + } +#endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); @@ -829,10 +866,18 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi info.ssl_cipher_list = ciphers; info.gid = -1; info.uid = -1; + + #if LWS_LIBRARY_VERSION_MAJOR >= 2 info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; #else info.options = 0; +#endif +#ifdef __FreeBSD__ + if (ipv4_only) { + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 0; + } #endif /* Create the secure WebSocket context */ admin_swss = lws_create_vhost(wsc, &info); From 90b43c1c473f8a1ff4c1a43b3c841fe37383401f Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Mon, 4 Jan 2021 22:34:26 +0100 Subject: [PATCH 04/12] Remove undefined ipv4_only --- transports/janus_websockets.c | 1 - 1 file changed, 1 deletion(-) diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index 3042e53bbc..9b2d87ac5f 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -669,7 +669,6 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi JANUS_LOG(LOG_ERR, "Invalid port (%s), falling back to default\n", item->value); wsport = 8989; } - ipv4_only = 0; char *interface = NULL; item = janus_config_get(config, config_general, janus_config_type_item, "wss_interface"); if(item && item->value) From 0ff09a248dd577020b174defec70b6d5bcbdc9cc Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Tue, 5 Jan 2021 18:47:56 +0100 Subject: [PATCH 05/12] indentation style and removal of dlerror() --- configure.ac | 2 +- janus.c | 1 - transports/janus_websockets.c | 36 +++++++++++++++++------------------ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index 8e3778ded4..fba29e8cbc 100644 --- a/configure.ac +++ b/configure.ac @@ -87,7 +87,7 @@ darwin*) AM_CONDITIONAL([DARWIN_OS], true) ;; freebsd*) - CFLAGS="$CFLAGS -I /usr/include/openssl" + CFLAGS="$CFLAGS -I/usr/include/openssl" LDFLAGS="$LDFLAGS -Xlinker --export-dynamic" LDFLAGS="$LDFLAGS -L/usr/lib/openssl -lcrypto -lssl -L/usr/local/lib" AM_CONDITIONAL([DARWIN_OS], false) diff --git a/janus.c b/janus.c index 2d5c20aa4d..144405752f 100644 --- a/janus.c +++ b/janus.c @@ -5333,7 +5333,6 @@ gint main(int argc, char *argv[]) if (!transport) { JANUS_LOG(LOG_ERR, "\tCouldn't load transport plugin '%s': %s\n", transportent->d_name, dlerror()); } else { - dlerror();//clear errors create_t *create = (create_t*) dlsym(transport, "create"); const char *dlsym_error = dlerror(); if (dlsym_error) { diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index 9b2d87ac5f..f9ff60b7af 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -592,6 +592,7 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #endif /* Force single-thread server */ wscinfo.count_threads = 1; + /* Create the base context */ wsc = lws_create_context(&wscinfo); if(wsc == NULL) { @@ -675,7 +676,6 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi interface = (char *)item->value; char *ip = NULL; item = janus_config_get(config, config_general, janus_config_type_item, "wss_ip"); - if(item && item->value) { ip = (char *)item->value; #ifdef __FreeBSD__ @@ -730,7 +730,7 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #ifdef __FreeBSD__ if(ipv4_only) { info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; - ipv4_only = 0; + ipv4_only = 0; } #endif /* Create the secure WebSocket context */ @@ -761,14 +761,13 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi char *ip = NULL; item = janus_config_get(config, config_admin, janus_config_type_item, "admin_ws_ip"); if(item && item->value) { - ip = (char *)item->value; + ip = (char *)item->value; #ifdef __FreeBSD__ - struct in_addr addr; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { - ipv4_only = 1; - } + struct in_addr addr; + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + ipv4_only = 1; + } #endif - char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip); @@ -790,11 +789,10 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi info.options = 0; #ifdef __FreeBSD__ if (ipv4_only) { - info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; - ipv4_only = 0; - } + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 0; + } #endif - /* Create the WebSocket context */ admin_wss = lws_create_vhost(wsc, &info); if(admin_wss == NULL) { @@ -821,12 +819,12 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi char *ip = NULL; item = janus_config_get(config, config_admin, janus_config_type_item, "admin_wss_ip"); if(item && item->value) { - ip = (char *)item->value; + ip = (char *)item->value; #ifdef __FreeBSD__ struct in_addr addr; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { - ipv4_only = 1; - } + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + ipv4_only = 1; + } #endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { @@ -874,9 +872,9 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #endif #ifdef __FreeBSD__ if (ipv4_only) { - info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; - ipv4_only = 0; - } + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 0; + } #endif /* Create the secure WebSocket context */ admin_swss = lws_create_vhost(wsc, &info); From eb8d9086793f6280276122fe25dfa245d055facd Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Wed, 6 Jan 2021 14:28:55 +0100 Subject: [PATCH 06/12] Style empty lines --- configure.ac | 4 ++-- transports/janus_websockets.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index fba29e8cbc..dba23f8270 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,7 @@ cc*) -Wunsafe-loop-optimizations \ -Wunused-but-set-variable" esac + JANUS_VERSION=110 AC_SUBST(JANUS_VERSION) JANUS_VERSION_STRING="0.10.10" @@ -345,6 +346,7 @@ AC_ARG_ENABLE([systemd-sockets], [Enable Systemd Unix Sockets management])], [], [enable_systemd_sockets=no]) + case "$host_os" in freebsd*) PKGCHECKMODULES="glib-2.0 >= $glib_version @@ -363,11 +365,9 @@ freebsd*) libssl >= $ssl_version libcrypto zlib" - esac PKG_CHECK_MODULES([JANUS],"$PKGCHECKMODULES") - JANUS_MANUAL_LIBS="${JANUS_MANUAL_LIBS} -lm" AC_SUBST(JANUS_MANUAL_LIBS) diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index f9ff60b7af..bd08ea481b 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -385,6 +385,7 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #ifndef LWS_WITH_IPV6 JANUS_LOG(LOG_WARN, "libwebsockets has been built without IPv6 support, will bind to IPv4 only\n"); #endif + #ifdef __FreeBSD__ int ipv4_only = 0; #endif @@ -726,7 +727,6 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #else info.options = 0; #endif - #ifdef __FreeBSD__ if(ipv4_only) { info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; @@ -863,8 +863,6 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi info.ssl_cipher_list = ciphers; info.gid = -1; info.uid = -1; - - #if LWS_LIBRARY_VERSION_MAJOR >= 2 info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; #else From 14a4673dcfb3147da8eb6be44d1172549dd50f2d Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Wed, 6 Jan 2021 16:02:45 +0100 Subject: [PATCH 07/12] Code style add spaces --- transports/janus_websockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index bd08ea481b..48fa42ffeb 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -649,7 +649,7 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi #ifdef __FreeBSD__ if (ipv4_only) { info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; - ipv4_only=0; + ipv4_only = 0; } #endif /* Create the WebSocket context */ From 054eabcff08a0d1862f2c20557fe66a3be6846a0 Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Thu, 14 Jan 2021 19:13:04 +0100 Subject: [PATCH 08/12] Update README and fix code style --- README.md | 28 ++++++---------------------- transports/janus_websockets.c | 12 ++++-------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index af56b1fde4..926e5cd21e 100644 --- a/README.md +++ b/README.md @@ -208,29 +208,13 @@ If Doxygen and graphviz are available, the process can also build the documentat You can also selectively enable/disable other features (e.g., specific plugins you don't care about, or whether or not you want to build the recordings post-processor). Use the --help option when configuring for more info. ### Building on FreeBSD - pkg install libsrtp2 \ - libusrsctp \ - jansson \ - libnice \ - libmicrohttpd \ - libwebsockets \ - curl \ - opus \ - sofia-sip \ - libogg \ - jansson \ - libnice \ - libconfig \ - libtool \ - gmake \ - autoconf \ - autoconf-wrapper \ - glib +When building on FreeBSD you can install the depencencies from ports or packages, here only pkg method is used. You also need to use gmake instead of make, +since it is a GNU makefile. ./configure can be run without arguments since the default prefix is /usr/local which is your default LOCALBASE. +Note that the configure.ac is coded to use openssl in base. If you wish to use openssl from ports or any other ssl you must change configure.ac accordingly. + + pkg install libsrtp2 libusrsctp jansson libnice libmicrohttpd libwebsockets curl opus sofia-sip libogg jansson libnice libconfig \ + libtool gmake autoconf autoconf-wrapper glib - sh autogen.sh - ./configure - gmake - gmake install ### Building on MacOS While most of the above instructions will work when compiling Janus on MacOS as well, there are a few aspects to highlight when doing that. diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index 48fa42ffeb..c0ec27dc5b 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -623,9 +623,8 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi ip = (char *)item->value; #ifdef __FreeBSD__ struct in_addr addr; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr)) > 0) ipv4_only = 1; - } #endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { @@ -681,9 +680,8 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi ip = (char *)item->value; #ifdef __FreeBSD__ struct in_addr addr; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr)) > 0) ipv4_only = 1; - } #endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { @@ -764,9 +762,8 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi ip = (char *)item->value; #ifdef __FreeBSD__ struct in_addr addr; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr)) > 0) ipv4_only = 1; - } #endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { @@ -822,9 +819,8 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi ip = (char *)item->value; #ifdef __FreeBSD__ struct in_addr addr; - if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) { + if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr)) > 0) ipv4_only = 1; - } #endif char *iface = janus_websockets_get_interface_name(ip); if(iface == NULL) { From 23a7751d2cad7d01401253f943d5b5f9186f4db2 Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Wed, 20 Jan 2021 17:41:42 +0100 Subject: [PATCH 09/12] Add note of unsupported rtp_forward on FreeBSD --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 926e5cd21e..622af95c37 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,11 @@ If Doxygen and graphviz are available, the process can also build the documentat You can also selectively enable/disable other features (e.g., specific plugins you don't care about, or whether or not you want to build the recordings post-processor). Use the --help option when configuring for more info. ### Building on FreeBSD +* *Note*: rtp_forward of streams only works streaming to IPv6, +because of [2051](https://github.com/meetecho/janus-gateway/issues/2051) and thus the feature +is not supported on FreeBSD at the moment + + When building on FreeBSD you can install the depencencies from ports or packages, here only pkg method is used. You also need to use gmake instead of make, since it is a GNU makefile. ./configure can be run without arguments since the default prefix is /usr/local which is your default LOCALBASE. Note that the configure.ac is coded to use openssl in base. If you wish to use openssl from ports or any other ssl you must change configure.ac accordingly. From b5925e3d5b93ce47d56165bd10f10ce6abc82d4a Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Thu, 28 Jan 2021 14:03:30 +0100 Subject: [PATCH 10/12] Add __FreeBSD__ in pp-rtp.h --- postprocessing/pp-rtp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postprocessing/pp-rtp.h b/postprocessing/pp-rtp.h index 958f79f48f..646ea5fe14 100644 --- a/postprocessing/pp-rtp.h +++ b/postprocessing/pp-rtp.h @@ -13,7 +13,7 @@ #ifndef JANUS_PP_RTP #define JANUS_PP_RTP -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #define __BYTE_ORDER BYTE_ORDER #define __BIG_ENDIAN BIG_ENDIAN From 4a2485907fe0dd2c60c9785e99d633738637beec Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Sun, 14 Feb 2021 19:54:29 +0100 Subject: [PATCH 11/12] Add missing defines for --enable-post-processing --- postprocessing/janus-pp-rec.c | 2 +- postprocessing/mjr2pcap.c | 2 +- postprocessing/pp-av1.c | 2 +- postprocessing/pp-binary.c | 2 +- postprocessing/pp-g711.c | 2 +- postprocessing/pp-g722.c | 2 +- postprocessing/pp-h264.c | 2 +- postprocessing/pp-h265.c | 2 +- postprocessing/pp-opus.c | 2 +- postprocessing/pp-srt.c | 2 +- postprocessing/pp-webm.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/postprocessing/janus-pp-rec.c b/postprocessing/janus-pp-rec.c index 5ff32ae7b4..49be2cdb01 100644 --- a/postprocessing/janus-pp-rec.c +++ b/postprocessing/janus-pp-rec.c @@ -88,7 +88,7 @@ Usage: janus-pp-rec [OPTIONS] source.mjr [destination.[opus|wav|webm|mp4|srt]] */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/mjr2pcap.c b/postprocessing/mjr2pcap.c index 3b5997fea9..7d9e7cce89 100644 --- a/postprocessing/mjr2pcap.c +++ b/postprocessing/mjr2pcap.c @@ -25,7 +25,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-av1.c b/postprocessing/pp-av1.c index c824ccba04..c211a01630 100644 --- a/postprocessing/pp-av1.c +++ b/postprocessing/pp-av1.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-binary.c b/postprocessing/pp-binary.c index 4bc4c62e5b..ae52eece63 100644 --- a/postprocessing/pp-binary.c +++ b/postprocessing/pp-binary.c @@ -12,7 +12,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-g711.c b/postprocessing/pp-g711.c index d6d78aee99..073cfe67dc 100644 --- a/postprocessing/pp-g711.c +++ b/postprocessing/pp-g711.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-g722.c b/postprocessing/pp-g722.c index b03670d697..d85506e8fc 100644 --- a/postprocessing/pp-g722.c +++ b/postprocessing/pp-g722.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined (__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-h264.c b/postprocessing/pp-h264.c index dfa639193e..bd02cb32aa 100644 --- a/postprocessing/pp-h264.c +++ b/postprocessing/pp-h264.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-h265.c b/postprocessing/pp-h265.c index 4e704b8110..d12aee8bfa 100644 --- a/postprocessing/pp-h265.c +++ b/postprocessing/pp-h265.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-opus.c b/postprocessing/pp-opus.c index 5dede3ef42..4eef9952e1 100644 --- a/postprocessing/pp-opus.c +++ b/postprocessing/pp-opus.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-srt.c b/postprocessing/pp-srt.c index cb8d2859e2..5eeed71b8c 100644 --- a/postprocessing/pp-srt.c +++ b/postprocessing/pp-srt.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include diff --git a/postprocessing/pp-webm.c b/postprocessing/pp-webm.c index cbf88f979c..17a394758f 100644 --- a/postprocessing/pp-webm.c +++ b/postprocessing/pp-webm.c @@ -10,7 +10,7 @@ */ #include -#ifdef __MACH__ +#if defined(__MACH__) || defined(__FreeBSD__) #include #else #include From 401f6211e7c1573bae82346d515cf3ee6932e36b Mon Sep 17 00:00:00 2001 From: Jesper Schmitz Mouridsen Date: Wed, 24 Mar 2021 18:56:24 +0100 Subject: [PATCH 12/12] Fix style Add missing gengetopt to dependencies pkg install --- README.md | 12 +++++------- transports/janus_websockets.c | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 622af95c37..3c86cac1a6 100644 --- a/README.md +++ b/README.md @@ -209,16 +209,14 @@ You can also selectively enable/disable other features (e.g., specific plugins y ### Building on FreeBSD * *Note*: rtp_forward of streams only works streaming to IPv6, -because of [2051](https://github.com/meetecho/janus-gateway/issues/2051) and thus the feature -is not supported on FreeBSD at the moment +because of #2051 and thus the feature is not supported on FreeBSD at the moment. - -When building on FreeBSD you can install the depencencies from ports or packages, here only pkg method is used. You also need to use gmake instead of make, -since it is a GNU makefile. ./configure can be run without arguments since the default prefix is /usr/local which is your default LOCALBASE. -Note that the configure.ac is coded to use openssl in base. If you wish to use openssl from ports or any other ssl you must change configure.ac accordingly. +When building on FreeBSD you can install the depencencies from ports or packages, here only pkg method is used. You also need to use `gmake` instead of `make`, +since it is a GNU makefile. `./configure` can be run without arguments since the default prefix is `/usr/local` which is your default `LOCALBASE`. +Note that the `configure.ac` is coded to use openssl in base. If you wish to use openssl from ports or any other ssl you must change `configure.ac` accordingly. pkg install libsrtp2 libusrsctp jansson libnice libmicrohttpd libwebsockets curl opus sofia-sip libogg jansson libnice libconfig \ - libtool gmake autoconf autoconf-wrapper glib + libtool gmake autoconf autoconf-wrapper glib gengetopt ### Building on MacOS diff --git a/transports/janus_websockets.c b/transports/janus_websockets.c index 0ef1ac5071..4784c32845 100644 --- a/transports/janus_websockets.c +++ b/transports/janus_websockets.c @@ -790,9 +790,9 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi info.options = 0; #ifdef __FreeBSD__ if (ipv4_only) { - info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; - ipv4_only = 0; - } + info.options |= LWS_SERVER_OPTION_DISABLE_IPV6; + ipv4_only = 0; + } #endif #if (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2) || (LWS_LIBRARY_VERSION_MAJOR > 3) info.options |= LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND;