module-rtp-sink: improve source.ip default

Use the default source.ip from the same address family as the
destination.ip.

See #3851
This commit is contained in:
Wim Taymans 2024-02-15 15:31:54 +01:00
parent 320eb935a3
commit 49e7e3a0f0

View file

@ -120,6 +120,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
@ -551,13 +552,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)
@ -566,6 +560,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);