From 65d5168c6dc1bae56bb1eabb6a5d0673c08a5459 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Tue, 3 Sep 2024 10:38:20 -0400 Subject: [PATCH] Add 'DISABLE_PEER_SIGNALING' Allows library to be used without MQTT/HTTP dependencies Resolves #102 --- src/config.h | 3 +++ src/peer_signaling.c | 2 ++ src/peer_signaling.h | 4 ++++ src/ssl_transport.c | 2 ++ src/ssl_transport.h | 3 +++ 5 files changed, 14 insertions(+) diff --git a/src/config.h b/src/config.h index bbfaeae..b40a281 100644 --- a/src/config.h +++ b/src/config.h @@ -25,4 +25,7 @@ // #define LOG_LEVEL LEVEL_DEBUG #define LOG_REDIRECT 0 +// Disable MQTT and HTTP signaling +// #define DISABLE_PEER_SIGNALING 1 + #endif // CONFIG_H_ diff --git a/src/peer_signaling.c b/src/peer_signaling.c index 3f4852e..3232865 100644 --- a/src/peer_signaling.c +++ b/src/peer_signaling.c @@ -1,3 +1,4 @@ +#ifndef DISABLE_PEER_SIGNALING #include #include #include @@ -526,3 +527,4 @@ void peer_signaling_set_config(ServiceConfiguration* service_config) { g_ps.pc = service_config->pc; peer_connection_onicecandidate(g_ps.pc, peer_signaling_onicecandidate); } +#endif // DISABLE_PEER_SIGNALING diff --git a/src/peer_signaling.h b/src/peer_signaling.h index 982c5d5..2a1608a 100644 --- a/src/peer_signaling.h +++ b/src/peer_signaling.h @@ -7,6 +7,8 @@ extern "C" { #endif +#ifndef DISABLE_PEER_SIGNALING + typedef struct ServiceConfiguration { const char* mqtt_url; int mqtt_port; @@ -46,4 +48,6 @@ int peer_signaling_loop(); } #endif +#endif // DISABLE_PEER_SIGNALING + #endif // PEER_SIGNALING_H_ diff --git a/src/ssl_transport.c b/src/ssl_transport.c index 9a9dbe3..e2a39d1 100644 --- a/src/ssl_transport.c +++ b/src/ssl_transport.c @@ -1,3 +1,4 @@ +#ifndef DISABLE_PEER_SIGNALING #include #include #include @@ -122,3 +123,4 @@ int ssl_transport_send(NetworkContext_t* net_ctx, const void* buf, size_t len) { return ret; } +#endif // DISABLE_PEER_SIGNALING diff --git a/src/ssl_transport.h b/src/ssl_transport.h index 95b8468..bc71291 100644 --- a/src/ssl_transport.h +++ b/src/ssl_transport.h @@ -1,6 +1,8 @@ #ifndef SSL_TRANSPORT_H_ #define SSL_TRANSPORT_H_ +#ifndef DISABLE_PEER_SIGNALING + #include #include #include @@ -29,4 +31,5 @@ int ssl_transport_recv(NetworkContext_t* net_ctx, void* buf, size_t len); int ssl_transport_send(NetworkContext_t* net_ctx, const void* buf, size_t len); +#ifndef // DISABLE_PEER_SIGNALING #endif // SSL_TRANSPORT_H_