diff options
author | Jason Parker <jparker@digium.com> | 2013-05-24 21:21:25 +0000 |
---|---|---|
committer | Jason Parker <jparker@digium.com> | 2013-05-24 21:21:25 +0000 |
commit | 154fbf8cae866269cb2b64a5cb26cb4d435cf4df (patch) | |
tree | bdf1e07244cfee6526570c3b9357da9378981150 /main/channel.c | |
parent | 1223199b3d18b82a931475f939170b9379e6afed (diff) |
Split Hold event into Hold/Unhold, and move it into core.
(closes issue ASTERISK-21487)
Review: https://reviewboard.asterisk.org/r/2565/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389746 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/main/channel.c b/main/channel.c index aec43edf7..f7aa0bf09 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1353,9 +1353,11 @@ static void publish_channel_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob) { RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); - if (blob) { - message = ast_channel_blob_create(chan, type, blob); + if (!blob) { + blob = ast_json_null(); } + + message = ast_channel_blob_create(chan, type, blob); if (message) { stasis_publish(ast_channel_topic(chan), message); } @@ -1405,6 +1407,39 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause) return res; } +int ast_queue_hold(struct ast_channel *chan, const char *musicclass) +{ + RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref); + RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); + struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HOLD }; + int res; + + if (!ast_strlen_zero(musicclass)) { + f.data.ptr = (void *) musicclass; + f.datalen = strlen(musicclass) + 1; + + blob = ast_json_pack("{s: s}", + "musicclass", musicclass); + } + + publish_channel_blob(chan, ast_channel_hold_type(), blob); + + res = ast_queue_frame(chan, &f); + return res; +} + +int ast_queue_unhold(struct ast_channel *chan) +{ + RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); + struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD }; + int res; + + publish_channel_blob(chan, ast_channel_unhold_type(), NULL); + + res = ast_queue_frame(chan, &f); + return res; +} + /*! \brief Queue a control frame */ int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control) { @@ -6694,7 +6729,7 @@ static void masquerade_colp_transfer(struct ast_channel *transferee, struct xfer /* Release any hold on the target. */ if (colp->target_held) { - ast_queue_control(transferee, AST_CONTROL_UNHOLD); + ast_queue_unhold(transferee); } /* |