From a7410fe1bfa5bf74b47b51f60d648236a70be0a5 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Wed, 20 Dec 2023 12:19:03 +0300 Subject: [PATCH] module-rtp-sap: refactor channelmap generation --- src/modules/module-rtp-sap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/module-rtp-sap.c b/src/modules/module-rtp-sap.c index e49884d83..dbcadbbc0 100644 --- a/src/modules/module-rtp-sap.c +++ b/src/modules/module-rtp-sap.c @@ -740,6 +740,9 @@ static struct session *session_new_announce(struct impl *impl, struct node *node if ((str = pw_properties_get(props, "rtp.ts-refclk")) != NULL) sdp->ts_refclk = strdup(str); if ((str = pw_properties_get(props, PW_KEY_NODE_CHANNELNAMES)) != NULL) { + struct spa_strbuf buf; + spa_strbuf_init(&buf, sdp->channelmap, sizeof(sdp->channelmap)); + struct spa_json it[2]; char v[256]; @@ -748,10 +751,9 @@ static struct session *session_new_announce(struct impl *impl, struct node *node spa_json_init(&it[1], str, strlen(str)); if (spa_json_get_string(&it[1], v, sizeof(v)) > 0) - snprintf(sdp->channelmap, sizeof(sdp->channelmap) - 1, "%s", v); + spa_strbuf_append(&buf, "%s", v); while (spa_json_get_string(&it[1], v, sizeof(v)) > 0) - snprintf(sdp->channelmap + strlen(sdp->channelmap), - sizeof(sdp->channelmap) - strlen(sdp->channelmap) - 1, ", %s", v); + spa_strbuf_append(&buf, ", %s", v); } pw_log_info("created new session for node:%u", node->id);