From b9dc4f8dd0aad93995190aa18add02d08abecb4c Mon Sep 17 00:00:00 2001 From: Oriol Capsada Date: Mon, 9 May 2022 19:31:53 +0200 Subject: [PATCH] Added custom headers for SIP SUBSCRIBE requests --- src/plugins/janus_sip.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/janus_sip.c b/src/plugins/janus_sip.c index e74ae65df1..8a6af54984 100644 --- a/src/plugins/janus_sip.c +++ b/src/plugins/janus_sip.c @@ -495,7 +495,8 @@ "event" : "", "accept" : "", "to" : "", - "subscribe_ttl" : "" + "subscribe_ttl" : "", + "headers" : "" } \endverbatim * @@ -780,7 +781,8 @@ static struct janus_json_parameter subscribe_parameters[] = { {"event", JSON_STRING, JANUS_JSON_PARAM_REQUIRED}, {"accept", JSON_STRING, 0}, {"subscribe_ttl", JANUS_JSON_INTEGER, 0}, - {"call_id", JANUS_JSON_STRING, 0} + {"call_id", JANUS_JSON_STRING, 0}, + {"headers", JSON_OBJECT, 0} }; static struct janus_json_parameter proxy_parameters[] = { {"proxy", JSON_STRING, 0}, @@ -3335,6 +3337,8 @@ static void *janus_sip_handler(void *data) { g_hash_table_insert(session->stack->subscriptions, g_strdup(event_type), nh); } janus_mutex_unlock(&session->stack->smutex); + char custom_headers[2048]; + janus_sip_parse_custom_headers(root, (char *)&custom_headers, sizeof(custom_headers)); /* Send the SUBSCRIBE */ nua_subscribe(nh, SIPTAG_TO_STR(to), @@ -3344,6 +3348,7 @@ static void *janus_sip_handler(void *data) { SIPTAG_EXPIRES_STR(ttl_text), NUTAG_PROXY(session->helper && session->master ? session->master->account.outbound_proxy : session->account.outbound_proxy), + TAG_IF(strlen(custom_headers) > 0, SIPTAG_HEADER_STR(custom_headers)), TAG_END()); result = json_object(); json_object_set_new(result, "event", json_string("subscribing"));