module-rtp-source: make SAP cleanup interval configurable

Audinate AES67 devices send SAP messages with 30-second interval, so hardcoded timeout has to be bumped. Just bumping it will reduce efficiency of common RTP module use-case, so a config is introduced for this. 70 second will be set as default for AES67 mode.
This commit is contained in:
Dmitry Sharshakov 2022-10-31 19:19:15 +03:00 committed by Wim Taymans
parent 03cb7f3549
commit f2c3baf93f

View file

@ -105,8 +105,8 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
#define ERROR_MSEC 2 #define ERROR_MSEC 2
#define MAX_SESSIONS 16 #define MAX_SESSIONS 16
#define CLEANUP_INTERVAL_SEC 20
#define DEFAULT_CLEANUP_INTERVAL_SEC 20
#define DEFAULT_SAP_IP "224.0.0.56" #define DEFAULT_SAP_IP "224.0.0.56"
#define DEFAULT_SAP_PORT 9875 #define DEFAULT_SAP_PORT 9875
#define DEFAULT_SESS_LATENCY 100 #define DEFAULT_SESS_LATENCY 100
@ -151,6 +151,7 @@ struct impl {
char *sap_ip; char *sap_ip;
int sap_port; int sap_port;
int sess_latency_msec; int sess_latency_msec;
uint32_t cleanup_interval;
struct spa_list sessions; struct spa_list sessions;
uint32_t n_sessions; uint32_t n_sessions;
@ -939,13 +940,16 @@ static void on_timer_event(void *data, uint64_t expirations)
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
timestamp = SPA_TIMESPEC_TO_NSEC(&now); timestamp = SPA_TIMESPEC_TO_NSEC(&now);
interval = CLEANUP_INTERVAL_SEC * SPA_NSEC_PER_SEC; interval = impl->cleanup_interval * SPA_NSEC_PER_SEC;
spa_list_for_each_safe(sess, tmp, &impl->sessions, link) { spa_list_for_each_safe(sess, tmp, &impl->sessions, link) {
if (sess->timestamp + interval < timestamp) if (sess->timestamp + interval < timestamp) {
pw_log_debug("More than %lu elapsed from last advertisement at %lu", interval, sess->timestamp);
pw_log_info("No advertisement packets found for timeout, closing RTP source");
session_free(sess); session_free(sess);
} }
} }
}
static void core_destroy(void *d) static void core_destroy(void *d)
{ {
@ -1067,6 +1071,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
"sap.port", DEFAULT_SAP_PORT); "sap.port", DEFAULT_SAP_PORT);
impl->sess_latency_msec = pw_properties_get_uint32(props, impl->sess_latency_msec = pw_properties_get_uint32(props,
"sess.latency.msec", DEFAULT_SESS_LATENCY); "sess.latency.msec", DEFAULT_SESS_LATENCY);
impl->cleanup_interval = pw_properties_get_uint32(props,
"sap.interval.sec", DEFAULT_CLEANUP_INTERVAL_SEC);
impl->core = pw_context_get_object(impl->module_context, PW_TYPE_INTERFACE_Core); impl->core = pw_context_get_object(impl->module_context, PW_TYPE_INTERFACE_Core);
if (impl->core == NULL) { if (impl->core == NULL) {
@ -1099,7 +1105,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
} }
value.tv_sec = 0; value.tv_sec = 0;
value.tv_nsec = 1; value.tv_nsec = 1;
interval.tv_sec = CLEANUP_INTERVAL_SEC; interval.tv_sec = impl->cleanup_interval;
interval.tv_nsec = 0; interval.tv_nsec = 0;
pw_loop_update_timer(impl->loop, impl->timer, &value, &interval, false); pw_loop_update_timer(impl->loop, impl->timer, &value, &interval, false);