Skip to content

Commit

Permalink
Added custom headers to 'decline' request (meetecho#2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihusejnovic authored Dec 2, 2020
1 parent 52e9a41 commit 9e1ea1e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugins/janus_sip.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@
\verbatim
{
"request" : "decline",
"code" : <SIP code to be sent, if not set, 486 is used; optional>"
"code" : <SIP code to be sent, if not set, 486 is used; optional>",
"headers" : "<array of key/value objects, to specify custom headers to add to the SIP request; optional>"
}
\endverbatim
*
Expand Down Expand Up @@ -742,6 +743,7 @@ static struct janus_json_parameter accept_parameters[] = {
};
static struct janus_json_parameter decline_parameters[] = {
{"code", JANUS_JSON_INTEGER, 0},
{"headers", JSON_OBJECT, 0},
{"refer_id", JANUS_JSON_INTEGER, 0}
};
static struct janus_json_parameter transfer_parameters[] = {
Expand Down Expand Up @@ -3973,7 +3975,12 @@ static void *janus_sip_handler(void *data) {
JANUS_LOG(LOG_WARN, "Invalid SIP response code specified, using 486 to decline call\n");
response_code = 486;
}
nua_respond(session->stack->s_nh_i, response_code, sip_status_phrase(response_code), TAG_END());
/* Check if the response needs to be enriched with custom headers */
char custom_headers[2048];
janus_sip_parse_custom_headers(root, (char *)&custom_headers, sizeof(custom_headers));
nua_respond(session->stack->s_nh_i, response_code, sip_status_phrase(response_code),
TAG_IF(strlen(custom_headers) > 0, SIPTAG_HEADER_STR(custom_headers)),
TAG_END());
janus_mutex_lock(&session->mutex);
/* Also notify event handlers */
if(notify_events && gateway->events_is_enabled()) {
Expand Down

0 comments on commit 9e1ea1e

Please sign in to comment.