module-rtp: Allow updating sess.name from params

We might want to add more such properties to be dynamically updated, but
just adding this one for now.
This commit is contained in:
Arun Raghavan 2024-06-28 12:04:05 -04:00
parent 59b9da9477
commit 02fea0ba8f

View file

@ -333,6 +333,8 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
const char *key;
struct spa_pod *pod;
const char *value;
struct spa_dict_item items[2];
unsigned int n_items = 0;
if (spa_pod_parse_object(param, SPA_TYPE_OBJECT_Props, NULL, SPA_PROP_params,
SPA_POD_OPT_Pod(&params)) < 0)
@ -341,7 +343,7 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
if (spa_pod_parser_push_struct(&prs, &f) < 0)
return;
while (true) {
while (n_items < SPA_N_ELEMENTS(items)) {
if (spa_pod_parser_get_string(&prs, &key) < 0)
break;
if (spa_pod_parser_get_pod(&prs, &pod) < 0)
@ -349,20 +351,22 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
if (spa_pod_get_string(pod, &value) < 0)
continue;
pw_log_info("key '%s', value '%s'", key, value);
if (!spa_streq(key, "destination.ip"))
continue;
if (spa_streq(key, "destination.ip")) {
if (pw_net_parse_address(value, impl->dst_port, &impl->dst_addr,
&impl->dst_len) < 0) {
pw_log_error("invalid destination.ip: '%s'", value);
break;
}
pw_properties_set(impl->stream_props, "rtp.destination.ip", value);
struct spa_dict_item item[1];
item[0] = SPA_DICT_ITEM_INIT("rtp.destination.ip", value);
rtp_stream_update_properties(impl->stream, &SPA_DICT_INIT(item, 1));
break;
items[n_items++] = SPA_DICT_ITEM_INIT("rtp.destination.ip", value);
} else if (spa_streq(key, "sess.name")) {
pw_properties_set(impl->stream_props, "sess.name", value);
items[n_items++] = SPA_DICT_ITEM_INIT("sess.name", value);
}
}
rtp_stream_update_properties(impl->stream, &SPA_DICT_INIT(items, n_items));
}
}
}