mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-23 13:09:00 +00:00
chan_pjsip: Add technology-specific off-nominal hangup cause to events.
Although the ISDN/Q.850/Q.931 hangup cause code is already part of the ARI and AMI hangup and channel destroyed events, it can be helpful to know what the actual channel technology code was if the call was unsuccessful. For PJSIP, it's the SIP response code. * A new "tech_hangupcause" field was added to the ast_channel structure along with ast_channel_tech_hangupcause() and ast_channel_tech_hangupcause_set() functions. It should only be set for off-nominal terminations. * chan_pjsip was modified to set the tech hangup cause in the chan_pjsip_hangup() and chan_pjsip_session_end() functions. This is a bit tricky because these two functions aren't always called in the same order. The channel that hangs up first will get chan_pjsip_session_end() called first which will trigger the core to call chan_pjsip_hangup() on itself, then call chan_pjsip_hangup() on the other channel. The other channel's chan_pjsip_session_end() function will get called last. Unfortunately, the other channel's HangupRequest events are sent before chan_pjsip has had a chance to set the tech hangupcause code so the HangupRequest events for that channel won't have the cause code set. The ChannelDestroyed and Hangup events however will have the code set for both channels. * A new "tech_cause" field was added to the ast_channel_snapshot_hangup structure. This is a public structure so a bit of refactoring was needed to preserve ABI compatibility. * The ARI ChannelHangupRequest and ChannelDestroyed events were modified to include the "tech_cause" parameter in the JSON for off-nominal terminations. The parameter is suppressed for nominal termination. * The AMI SoftHangupRequest, HangupRequest and Hangup events were modified to include the "TechCause" parameter for off-nominal terminations. Like their ARI counterparts, the parameter is suppressed for nominal termination. DeveloperNote: A "tech_cause" parameter has been added to the ChannelHangupRequest and ChannelDestroyed ARI event messages and a "TechCause" parameter has been added to the HangupRequest, SoftHangupRequest and Hangup AMI event messages. For chan_pjsip, these will be set to the last SIP response status code for off-nominally terminated calls. The parameter is suppressed for nominal termination.
This commit is contained in:
committed by
github-actions[bot]
parent
ff0523a3d0
commit
5766460cc7
@@ -402,17 +402,30 @@ static struct ast_json *channel_destroyed_event(
|
||||
const struct timeval *tv)
|
||||
{
|
||||
struct ast_json *json_channel = ast_channel_snapshot_to_json(snapshot, stasis_app_get_sanitizer());
|
||||
struct ast_json *blob;
|
||||
|
||||
if (!json_channel) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ast_json_pack("{s: s, s: o, s: i, s: s, s: o}",
|
||||
blob = ast_json_pack("{s: s, s: o, s: i, s: s}",
|
||||
"type", "ChannelDestroyed",
|
||||
"timestamp", ast_json_timeval(*tv, NULL),
|
||||
"cause", snapshot->hangup->cause,
|
||||
"cause_txt", ast_cause2str(snapshot->hangup->cause),
|
||||
"channel", json_channel);
|
||||
"cause_txt", ast_cause2str(snapshot->hangup->cause));
|
||||
|
||||
if (!blob) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (snapshot->hangup->tech_cause) {
|
||||
ast_json_object_set(blob, "tech_cause",
|
||||
ast_json_integer_create(snapshot->hangup->tech_cause));
|
||||
}
|
||||
|
||||
ast_json_object_set(blob, "channel", json_channel);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
static struct ast_json *channel_state_change_event(
|
||||
|
Reference in New Issue
Block a user