diff options
author | Matthew Jordan <mjordan@digium.com> | 2015-04-07 15:21:17 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2015-04-07 15:21:17 +0000 |
commit | ab803ec3422e5377b5aa4769fbcc6b315d167d8b (patch) | |
tree | d86d3c961bbd420fd8f99952660159391d956fc6 /main/manager_channels.c | |
parent | 488f093e97b52a1337c7f480aac16f27bf3908b1 (diff) |
ARI: Add the ability to intercept hold and raise an event
For some applications - such as SLA - a phone pressing hold should not behave
in the fashion that the Asterisk core would like it to. Instead, the hold
action has some application specific behaviour associated with it - such as
disconnecting the channel that initiated the hold; only playing MoH to channels
in the bridge if the channels are of a particular type, etc.
One way of accomplishing this is to use a framehook to intercept the
hold/unhold frames, raise an event, and eat the frame. Tasty. This patch
accomplishes that using a new dialplan function, HOLD_INTERCEPT.
In addition, some general cleanup of raising hold/unhold Stasis messages was
done, including removing some RAII_VAR usage.
Review: https://reviewboard.asterisk.org/r/4549/
ASTERISK-24922 #close
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434216 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/manager_channels.c')
-rw-r--r-- | main/manager_channels.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/main/manager_channels.c b/main/manager_channels.c index f6dc46cec..3aaab92d0 100644 --- a/main/manager_channels.c +++ b/main/manager_channels.c @@ -1061,20 +1061,22 @@ static void channel_hold_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message) { struct ast_channel_blob *obj = stasis_message_data(message); - const char *musicclass; - RAII_VAR(struct ast_str *, musicclass_string, NULL, ast_free); - RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free); + struct ast_str *musicclass_string = ast_str_create(32); + struct ast_str *channel_event_string; - if (!(musicclass_string = ast_str_create(32))) { + if (!musicclass_string) { return; } channel_event_string = ast_manager_build_channel_state_string(obj->snapshot); if (!channel_event_string) { + ast_free(musicclass_string); return; } if (obj->blob) { + const char *musicclass; + musicclass = ast_json_string_get(ast_json_object_get(obj->blob, "musicclass")); if (!ast_strlen_zero(musicclass)) { @@ -1087,13 +1089,16 @@ static void channel_hold_cb(void *data, struct stasis_subscription *sub, "%s", ast_str_buffer(channel_event_string), ast_str_buffer(musicclass_string)); + + ast_free(musicclass_string); + ast_free(channel_event_string); } static void channel_unhold_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message) { struct ast_channel_blob *obj = stasis_message_data(message); - RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free); + struct ast_str *channel_event_string; channel_event_string = ast_manager_build_channel_state_string(obj->snapshot); if (!channel_event_string) { @@ -1103,6 +1108,8 @@ static void channel_unhold_cb(void *data, struct stasis_subscription *sub, manager_event(EVENT_FLAG_CALL, "Unhold", "%s", ast_str_buffer(channel_event_string)); + + ast_free(channel_event_string); } static void manager_channels_shutdown(void) |