From c2f50ba6f47e04c0457baa0bb5bf84b22a26d20b Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Tue, 7 Apr 2015 15:22:42 +0000 Subject: 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 ........ Merged revisions 434216 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434217 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/bridge_channel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main/bridge_channel.c') diff --git a/main/bridge_channel.c b/main/bridge_channel.c index 29e7cf0f6..c25d827cb 100644 --- a/main/bridge_channel.c +++ b/main/bridge_channel.c @@ -979,7 +979,8 @@ int ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_chan int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class) { - RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref); + struct ast_json *blob; + int res; size_t datalen; if (!ast_strlen_zero(moh_class)) { @@ -990,12 +991,16 @@ int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, con } else { moh_class = NULL; datalen = 0; + blob = NULL; } ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_hold_type(), blob); - return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD, + res = ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD, moh_class, datalen); + + ast_json_unref(blob); + return res; } int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel) -- cgit v1.2.3