diff --git a/src/modules/module-rtp-sink.c b/src/modules/module-rtp-sink.c index c4a041e3d..84b280c6d 100644 --- a/src/modules/module-rtp-sink.c +++ b/src/modules/module-rtp-sink.c @@ -52,9 +52,14 @@ * - `net.mtu = `: MTU to use, default 1280 * - `net.ttl = `: TTL to use, default 1 * - `net.loop = `: loopback multicast, default false - * - `sess.min-ptime = `: minimum packet time in milliseconds, default 2 - * - `sess.max-ptime = `: maximum packet time in milliseconds, default 20 + * - `sess.min-ptime = `: minimum packet time in milliseconds, default 2 + * - `sess.max-ptime = `: maximum packet time in milliseconds, default 20 * - `sess.name = `: a session name + * - `rtp.ptime = `: size of the packets in milliseconds, default up to MTU but + * between sess.min-ptime and sess.max-ptime + * - `rtp.framecount = `: number of samples per packet, default up to MTU but + * between sess.min-ptime and sess.max-ptime + * - `sess.latency.msec = `: target node latency in milliseconds, default as rtp.ptime * - `sess.ts-offset = `: an offset to apply to the timestamp, default -1 = random offset * - `sess.ts-refclk = `: the name of a reference clock * - `sess.media = `: the media type audio|midi|opus, default audio diff --git a/src/modules/module-rtp-source.c b/src/modules/module-rtp-source.c index 9be0facaa..62c8eb7d2 100644 --- a/src/modules/module-rtp-source.c +++ b/src/modules/module-rtp-source.c @@ -56,7 +56,7 @@ * you want to receive packets from or 0.0.0.0 to receive from any source address. * - `source.port = `: the source port * - `node.always-process = `: true to receive even when not running - * - `sess.latency.msec = `: target network latency in milliseconds, default 100 + * - `sess.latency.msec = `: target network latency in milliseconds, default 100 * - `sess.ignore-ssrc = `: ignore SSRC, default false * - `sess.media = `: the media type audio|midi|opus, default audio * - `stream.props = {}`: properties to be passed to the stream diff --git a/src/modules/module-rtp/stream.c b/src/modules/module-rtp/stream.c index aca21212f..7f5303506 100644 --- a/src/modules/module-rtp/stream.c +++ b/src/modules/module-rtp/stream.c @@ -284,7 +284,7 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core, float min_ptime, max_ptime; const struct spa_pod *params[1]; enum pw_stream_flags flags; - int latency_msec; + float latency_msec; int res; impl = calloc(1, sizeof(*impl)); @@ -450,16 +450,23 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core, pw_properties_setf(props, "rtp.framecount", "%u", impl->psamples); } } - latency_msec = pw_properties_get_uint32(props, - "sess.latency.msec", DEFAULT_SESS_LATENCY); + /* For senders, the default latency is ptime and for a receiver it is + * DEFAULT_SESS_LATENCY. Setting the sess.latency.msec for a sender to + * something smaller/bigger will influence the quantum and the amount + * of packets we send in one cycle */ + str = pw_properties_get(props, "sess.latency.msec"); + if (!spa_atof(str, &latency_msec)) { + latency_msec = direction == PW_DIRECTION_INPUT ? + samples_to_msec(impl, impl->psamples) : + DEFAULT_SESS_LATENCY; + } impl->target_buffer = msec_to_samples(impl, latency_msec); impl->max_error = msec_to_samples(impl, ERROR_MSEC); pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", impl->rate); if (direction == PW_DIRECTION_INPUT) { - // TODO: make sess.latency.msec work for sender streams pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", - impl->psamples, impl->rate); + impl->target_buffer, impl->rate); } else { pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", impl->target_buffer / 2, impl->rate); diff --git a/src/modules/module-rtp/stream.h b/src/modules/module-rtp/stream.h index 81f7a1472..96f6416c2 100644 --- a/src/modules/module-rtp/stream.h +++ b/src/modules/module-rtp/stream.h @@ -16,12 +16,12 @@ struct rtp_stream; #define DEFAULT_CHANNELS 2 #define DEFAULT_POSITION "[ FL FR ]" -#define ERROR_MSEC 2 -#define DEFAULT_SESS_LATENCY 100 +#define ERROR_MSEC 2.0f +#define DEFAULT_SESS_LATENCY 100.0f #define DEFAULT_MTU 1280 -#define DEFAULT_MIN_PTIME 2 -#define DEFAULT_MAX_PTIME 20 +#define DEFAULT_MIN_PTIME 2.0f +#define DEFAULT_MAX_PTIME 20.0f struct rtp_stream_events { #define RTP_VERSION_STREAM_EVENTS 0