rtp: take into account ipv4/ipv6 when calculating header size

Calculate the header_size based on the IP version instead of using a
hardcoded value.

Fixes #4524
This commit is contained in:
Wim Taymans 2025-01-24 12:43:34 +01:00
parent 180967bb64
commit 830bd19ca2
4 changed files with 22 additions and 4 deletions

View file

@ -487,6 +487,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
const char *str, *sess_name;
int64_t ts_offset;
int res = 0;
uint32_t header_size;
PW_LOG_TOPIC_INIT(mod_topic);
@ -584,6 +585,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
ts_offset = pw_rand32();
pw_properties_setf(stream_props, "rtp.sender-ts-offset", "%u", (uint32_t)ts_offset);
header_size = impl->dst_addr.ss_family == AF_INET ?
IP4_HEADER_SIZE : IP6_HEADER_SIZE;
header_size += UDP_HEADER_SIZE;
pw_properties_setf(stream_props, "net.header", "%u", header_size);
pw_net_get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
pw_properties_set(stream_props, "rtp.source.ip", addr);
pw_net_get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);