mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
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:
parent
180967bb64
commit
830bd19ca2
4 changed files with 22 additions and 4 deletions
|
|
@ -487,6 +487,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
const char *str, *sess_name;
|
const char *str, *sess_name;
|
||||||
int64_t ts_offset;
|
int64_t ts_offset;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
uint32_t header_size;
|
||||||
|
|
||||||
PW_LOG_TOPIC_INIT(mod_topic);
|
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();
|
ts_offset = pw_rand32();
|
||||||
pw_properties_setf(stream_props, "rtp.sender-ts-offset", "%u", (uint32_t)ts_offset);
|
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_net_get_ip(&impl->src_addr, addr, sizeof(addr), NULL, NULL);
|
||||||
pw_properties_set(stream_props, "rtp.source.ip", addr);
|
pw_properties_set(stream_props, "rtp.source.ip", addr);
|
||||||
pw_net_get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);
|
pw_net_get_ip(&impl->dst_addr, addr, sizeof(addr), NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -564,6 +564,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
int64_t ts_offset;
|
int64_t ts_offset;
|
||||||
char addr[128];
|
char addr[128];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
uint32_t header_size;
|
||||||
|
|
||||||
PW_LOG_TOPIC_INIT(mod_topic);
|
PW_LOG_TOPIC_INIT(mod_topic);
|
||||||
|
|
||||||
|
|
@ -644,6 +645,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
pw_properties_set(stream_props, "rtp.source.ip", addr);
|
pw_properties_set(stream_props, "rtp.source.ip", addr);
|
||||||
pw_properties_setf(stream_props, "rtp.source.port", "%u", impl->src_port);
|
pw_properties_setf(stream_props, "rtp.source.port", "%u", impl->src_port);
|
||||||
|
|
||||||
|
header_size = impl->src_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);
|
||||||
|
|
||||||
ts_offset = pw_properties_get_int64(props, "sess.ts-offset", DEFAULT_TS_OFFSET);
|
ts_offset = pw_properties_get_int64(props, "sess.ts-offset", DEFAULT_TS_OFFSET);
|
||||||
if (ts_offset == -1)
|
if (ts_offset == -1)
|
||||||
ts_offset = pw_rand32();
|
ts_offset = pw_rand32();
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ struct impl {
|
||||||
uint32_t ts_offset;
|
uint32_t ts_offset;
|
||||||
uint32_t psamples;
|
uint32_t psamples;
|
||||||
uint32_t mtu;
|
uint32_t mtu;
|
||||||
|
uint32_t header_size;
|
||||||
uint32_t payload_size;
|
uint32_t payload_size;
|
||||||
|
|
||||||
struct spa_ringbuffer ring;
|
struct spa_ringbuffer ring;
|
||||||
|
|
@ -442,11 +443,14 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core,
|
||||||
|
|
||||||
impl->payload = pw_properties_get_uint32(props, "rtp.payload", impl->payload);
|
impl->payload = pw_properties_get_uint32(props, "rtp.payload", impl->payload);
|
||||||
impl->mtu = pw_properties_get_uint32(props, "net.mtu", DEFAULT_MTU);
|
impl->mtu = pw_properties_get_uint32(props, "net.mtu", DEFAULT_MTU);
|
||||||
if (impl->mtu <= PACKET_HEADER_SIZE) {
|
impl->header_size = pw_properties_get_uint32(props, "net.header", IP4_HEADER_SIZE + UDP_HEADER_SIZE);
|
||||||
|
impl->header_size += RTP_HEADER_SIZE;
|
||||||
|
|
||||||
|
if (impl->mtu <= impl->header_size) {
|
||||||
pw_log_error("invalid MTU %d, using %d", impl->mtu, DEFAULT_MTU);
|
pw_log_error("invalid MTU %d, using %d", impl->mtu, DEFAULT_MTU);
|
||||||
impl->mtu = DEFAULT_MTU;
|
impl->mtu = DEFAULT_MTU;
|
||||||
}
|
}
|
||||||
impl->payload_size = impl->mtu - PACKET_HEADER_SIZE;
|
impl->payload_size = impl->mtu - impl->header_size;
|
||||||
|
|
||||||
impl->seq = pw_rand32();
|
impl->seq = pw_rand32();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,11 @@ struct rtp_stream;
|
||||||
#define ERROR_MSEC 2.0f
|
#define ERROR_MSEC 2.0f
|
||||||
#define DEFAULT_SESS_LATENCY 100.0f
|
#define DEFAULT_SESS_LATENCY 100.0f
|
||||||
|
|
||||||
/* 28 bytes IP/UDP, 12 bytes RTP header */
|
#define IP4_HEADER_SIZE 20
|
||||||
#define PACKET_HEADER_SIZE (12+28)
|
#define IP6_HEADER_SIZE 40
|
||||||
|
#define UDP_HEADER_SIZE 8
|
||||||
|
/* 12 bytes RTP header */
|
||||||
|
#define RTP_HEADER_SIZE 12
|
||||||
|
|
||||||
#define DEFAULT_MTU 1280
|
#define DEFAULT_MTU 1280
|
||||||
#define DEFAULT_MIN_PTIME 2.0f
|
#define DEFAULT_MIN_PTIME 2.0f
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue