-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kgenjac/save sip reason state on callback #3210
Changes from all commits
06e51c4
56ce055
9e7fc3a
35a7f01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1504,6 +1504,7 @@ static void janus_sip_media_reset(janus_sip_session *session) { | |
gpointer janus_sip_sofia_thread(gpointer user_data); | ||
/* Sofia callbacks */ | ||
void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]); | ||
void janus_sip_save_reason(sip_t const *sip, janus_sip_session *session); | ||
/* SDP parsing and manipulation */ | ||
void janus_sip_sdp_process(janus_sip_session *session, janus_sdp *sdp, gboolean answer, gboolean update, gboolean *changed); | ||
char *janus_sip_sdp_manipulate(janus_sip_session *session, janus_sdp *sdp, gboolean answer); | ||
|
@@ -5121,30 +5122,12 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, | |
break; | ||
case nua_i_bye: { | ||
JANUS_LOG(LOG_VERB, "[%s][%s]: %d %s\n", session->account.username, nua_event_name(event), status, phrase ? phrase : "??"); | ||
if(sip->sip_reason && sip->sip_reason->re_text) { | ||
session->hangup_reason_header = g_strdup(sip->sip_reason->re_text); | ||
janus_sip_remove_quotes(session->hangup_reason_header); | ||
} | ||
if(sip->sip_reason && sip->sip_reason->re_protocol) { | ||
session->hangup_reason_header_protocol = g_strdup(sip->sip_reason->re_protocol); | ||
} | ||
if(sip->sip_reason && sip->sip_reason->re_cause) { | ||
session->hangup_reason_header_cause = g_strdup(sip->sip_reason->re_cause); | ||
} | ||
janus_sip_save_reason(sip, session); | ||
break; | ||
} | ||
case nua_i_cancel: { | ||
JANUS_LOG(LOG_VERB, "[%s][%s]: %d %s\n", session->account.username, nua_event_name(event), status, phrase ? phrase : "??"); | ||
if(sip->sip_reason && sip->sip_reason->re_text) { | ||
session->hangup_reason_header = g_strdup(sip->sip_reason->re_text); | ||
janus_sip_remove_quotes(session->hangup_reason_header); | ||
} | ||
if(sip->sip_reason && sip->sip_reason->re_protocol) { | ||
session->hangup_reason_header_protocol = g_strdup(sip->sip_reason->re_protocol); | ||
} | ||
if(sip->sip_reason && sip->sip_reason->re_cause) { | ||
session->hangup_reason_header_cause = g_strdup(sip->sip_reason->re_cause); | ||
} | ||
janus_sip_save_reason(sip, session); | ||
break; | ||
} | ||
case nua_i_invite: { | ||
|
@@ -5788,6 +5771,7 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, | |
break; | ||
} | ||
} else if(status == 401 || status == 407) { | ||
janus_sip_save_reason(sip, session); | ||
const char *scheme = NULL; | ||
const char *realm = NULL; | ||
if(status == 401) { | ||
|
@@ -5846,6 +5830,7 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, | |
} else if(status == 700) { | ||
JANUS_LOG(LOG_VERB, "Handling SDP answer in ACK\n"); | ||
} else if(status >= 400 && status != 700) { | ||
janus_sip_save_reason(sip, session); | ||
break; | ||
} | ||
if(ssip == NULL) { | ||
|
@@ -6300,6 +6285,22 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, | |
} | ||
} | ||
|
||
void janus_sip_save_reason(sip_t const *sip, janus_sip_session *session) { | ||
if (!sip || !session) | ||
return; | ||
|
||
if (sip->sip_reason && sip->sip_reason->re_text) { | ||
session->hangup_reason_header = g_strdup(sip->sip_reason->re_text); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add a
before the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah actually I see they're freed in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I saw that it is freed in |
||
janus_sip_remove_quotes(session->hangup_reason_header); | ||
} | ||
if (sip->sip_reason && sip->sip_reason->re_protocol) { | ||
session->hangup_reason_header_protocol = g_strdup(sip->sip_reason->re_protocol); | ||
} | ||
if (sip->sip_reason && sip->sip_reason->re_cause) { | ||
session->hangup_reason_header_cause = g_strdup(sip->sip_reason->re_cause); | ||
} | ||
} | ||
|
||
void janus_sip_sdp_process(janus_sip_session *session, janus_sdp *sdp, gboolean answer, gboolean update, gboolean *changed) { | ||
if(!session || !sdp) | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea about the helper method! This should probably be
static
, but I see other functions aren't either, so that's something I can fix myself in a later commit.