diff --git a/src/modules/module-sendspin-recv.c b/src/modules/module-sendspin-recv.c index 4875cd597..526a56912 100644 --- a/src/modules/module-sendspin-recv.c +++ b/src/modules/module-sendspin-recv.c @@ -30,12 +30,15 @@ #include #include -#include "zeroconf-utils/zeroconf.h" #include "module-sendspin/sendspin.h" #include "module-sendspin/websocket.h" #include "module-sendspin/regress.h" #include "network-utils.h" +#ifdef HAVE_AVAHI +#include "zeroconf-utils/zeroconf.h" +#endif + /** \page page_module_sendspin_recv sendspin receiver * * The `sendspin-recv` module creates a PipeWire source that receives audio @@ -196,8 +199,10 @@ struct impl { struct spa_hook core_proxy_listener; unsigned int do_disconnect:1; +#ifdef HAVE_AVAHI struct pw_zeroconf *zeroconf; struct spa_hook zeroconf_listener; +#endif bool always_process; bool single_server; @@ -1005,16 +1010,6 @@ static void client_connected(struct client *c, struct pw_websocket_connection *c &websocket_connection_events, c); } -static struct client *client_find(struct impl *impl, const char *name) -{ - struct client *c; - spa_list_for_each(c, &impl->clients, link) { - if (spa_streq(c->name, name)) - return c; - } - return NULL; -} - struct match_info { struct impl *impl; const char *name; @@ -1045,7 +1040,7 @@ static int rule_matched(void *data, const char *location, const char *action, return res; } -static int match_client(struct impl *impl, const char *name, struct pw_properties *props, +static inline int match_client(struct impl *impl, const char *name, struct pw_properties *props, struct pw_websocket_connection *conn) { const char *str; @@ -1109,6 +1104,17 @@ static const struct pw_websocket_events websocket_events = { .connected = on_websocket_connected, }; +#ifdef HAVE_AVAHI +static struct client *client_find(struct impl *impl, const char *name) +{ + struct client *c; + spa_list_for_each(c, &impl->clients, link) { + if (spa_streq(c->name, name)) + return c; + } + return NULL; +} + static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; @@ -1157,6 +1163,7 @@ static const struct pw_zeroconf_events zeroconf_events = { .added = on_zeroconf_added, .removed = on_zeroconf_removed, }; +#endif static void core_destroy(void *d) { @@ -1234,7 +1241,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) const char *str, *hostname, *port, *path; struct pw_properties *props, *stream_props; int res = 0; - bool autoconnect, announce; + bool autoconnect; PW_LOG_TOPIC_INIT(mod_topic); @@ -1281,7 +1288,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) PW_KEY_NODE_ALWAYS_PROCESS, true); autoconnect = pw_properties_get_bool(props, "sendspin.autoconnect", false); - announce = pw_properties_get_bool(props, "sendspin.announce", true); impl->single_server = pw_properties_get_bool(props, "sendspin.single-server", true); @@ -1317,10 +1323,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) pw_websocket_add_listener(impl->websocket, &impl->websocket_listener, &websocket_events, impl); +#ifdef HAVE_AVAHI if ((impl->zeroconf = pw_zeroconf_new(context, NULL)) != NULL) { pw_zeroconf_add_listener(impl->zeroconf, &impl->zeroconf_listener, &zeroconf_events, impl); } +#endif hostname = pw_properties_get(props, "sendspin.ip"); /* a client should either connect itself or advertize itself and listen @@ -1336,6 +1344,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) pw_websocket_listen(impl->websocket, NULL, hostname, port, path); +#ifdef HAVE_AVAHI + bool announce = pw_properties_get_bool(props, "sendspin.announce", true); if (impl->zeroconf && announce) { /* optionally announce ourselves */ str = pw_properties_get(props, "sendspin.client-id"); @@ -1346,6 +1356,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) SPA_DICT_ITEM(PW_KEY_ZEROCONF_PORT, port), SPA_DICT_ITEM("path", path))); } +#endif } else { if (hostname != NULL) { @@ -1368,11 +1379,13 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) client_connect(c); } /* connect to zeroconf server if we can */ +#ifdef HAVE_AVAHI if (impl->zeroconf) { pw_zeroconf_set_browse(impl->zeroconf, NULL, &SPA_DICT_ITEMS( SPA_DICT_ITEM(PW_KEY_ZEROCONF_TYPE, PW_SENDSPIN_SERVER_SERVICE_TYPE))); } +#endif } pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl); diff --git a/src/modules/module-sendspin-send.c b/src/modules/module-sendspin-send.c index 3b6093307..6947ebb3c 100644 --- a/src/modules/module-sendspin-send.c +++ b/src/modules/module-sendspin-send.c @@ -32,9 +32,12 @@ #include "module-sendspin/sendspin.h" #include "module-sendspin/websocket.h" -#include "zeroconf-utils/zeroconf.h" #include "network-utils.h" +#ifdef HAVE_AVAHI +#include "zeroconf-utils/zeroconf.h" +#endif + /** \page page_module_sendspin_send sendspin sender * * The `sendspin-send` module creates a PipeWire sink that sends audio @@ -217,8 +220,10 @@ struct impl { struct spa_hook core_proxy_listener; unsigned int do_disconnect:1; +#ifdef HAVE_AVAHI struct pw_zeroconf *zeroconf; struct spa_hook zeroconf_listener; +#endif float delay; bool always_process; @@ -1009,16 +1014,6 @@ static void client_connected(struct client *c, struct pw_websocket_connection *c &websocket_connection_events, c); } -static struct client *client_find(struct impl *impl, const char *name) -{ - struct client *c; - spa_list_for_each(c, &impl->clients, link) { - if (spa_streq(c->name, name)) - return c; - } - return NULL; -} - struct match_info { struct impl *impl; const char *name; @@ -1110,6 +1105,17 @@ static const struct pw_websocket_events websocket_events = { .connected = on_websocket_connected, }; +#ifdef HAVE_AVAHI +static struct client *client_find(struct impl *impl, const char *name) +{ + struct client *c; + spa_list_for_each(c, &impl->clients, link) { + if (spa_streq(c->name, name)) + return c; + } + return NULL; +} + static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; @@ -1155,6 +1161,7 @@ static const struct pw_zeroconf_events zeroconf_events = { .added = on_zeroconf_added, .removed = on_zeroconf_removed, }; +#endif static void core_destroy(void *d) { @@ -1180,8 +1187,10 @@ static void impl_destroy(struct impl *impl) if (impl->data_loop) pw_context_release_loop(impl->context, impl->data_loop); +#ifdef HAVE_AVAHI if (impl->zeroconf) pw_zeroconf_destroy(impl->zeroconf); +#endif pw_properties_free(impl->stream_props); pw_properties_free(impl->props); @@ -1322,10 +1331,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) str = SPA_STRINGIFY(DEFAULT_SENDSPIN_DELAY); impl->delay = pw_properties_parse_float(str); +#ifdef HAVE_AVAHI if ((impl->zeroconf = pw_zeroconf_new(context, NULL)) != NULL) { pw_zeroconf_add_listener(impl->zeroconf, &impl->zeroconf_listener, &zeroconf_events, impl); } +#endif hostname = pw_properties_get(props, "sendspin.ip"); if (hostname != NULL) { @@ -1364,6 +1375,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) pw_websocket_listen(impl->websocket, NULL, hostname, port, path); +#ifdef HAVE_AVAHI if (impl->zeroconf) { str = pw_properties_get(props, "sendspin.group-name"); pw_zeroconf_set_announce(impl->zeroconf, NULL, @@ -1373,12 +1385,15 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) SPA_DICT_ITEM(PW_KEY_ZEROCONF_PORT, port), SPA_DICT_ITEM("path", path))); } +#endif } +#ifdef HAVE_AVAHI if (impl->zeroconf) { pw_zeroconf_set_browse(impl->zeroconf, NULL, &SPA_DICT_ITEMS( SPA_DICT_ITEM(PW_KEY_ZEROCONF_TYPE, PW_SENDSPIN_CLIENT_SERVICE_TYPE))); } +#endif pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl); pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_info));