From 0fba5537edb56fef5f6c1a8aafe9c2096c6398ea Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 15 Feb 2024 15:31:54 +0100 Subject: [PATCH] module-rtp-sink: improve source.ip default Use the default source.ip from the same address family as the destination.ip. See #3851 --- src/modules/module-rtp-sink.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/module-rtp-sink.c b/src/modules/module-rtp-sink.c index 0290e383e..3f8e0a7d0 100644 --- a/src/modules/module-rtp-sink.c +++ b/src/modules/module-rtp-sink.c @@ -115,6 +115,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); #define DEFAULT_PORT 46000 #define DEFAULT_SOURCE_IP "0.0.0.0" +#define DEFAULT_SOURCE_IP6 "::" #define DEFAULT_DESTINATION_IP "224.0.0.56" #define DEFAULT_TTL 1 #define DEFAULT_LOOP false @@ -470,13 +471,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) str = pw_properties_get(props, "local.ifname"); impl->ifname = str ? strdup(str) : NULL; - if ((str = pw_properties_get(props, "source.ip")) == NULL) - str = DEFAULT_SOURCE_IP; - if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) { - pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res)); - goto out; - } - impl->dst_port = DEFAULT_PORT + ((uint32_t) (pw_rand32() % 512) << 1); impl->dst_port = pw_properties_get_uint32(props, "destination.port", impl->dst_port); if ((str = pw_properties_get(props, "destination.ip")) == NULL) @@ -485,6 +479,13 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) pw_log_error("invalid destination.ip %s: %s", str, spa_strerror(res)); goto out; } + if ((str = pw_properties_get(props, "source.ip")) == NULL) + str = impl->dst_addr.ss_family == AF_INET ? + DEFAULT_SOURCE_IP : DEFAULT_SOURCE_IP6; + if ((res = parse_address(str, 0, &impl->src_addr, &impl->src_len)) < 0) { + pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res)); + goto out; + } impl->ttl = pw_properties_get_uint32(props, "net.ttl", DEFAULT_TTL); impl->mcast_loop = pw_properties_get_bool(props, "net.loop", DEFAULT_LOOP);