[asterisk-users] Call Hold / Transfer via AMI

Dan Cropp dan at amtelco.com
Wed Jul 21 15:41:23 CDT 2021


We found no way to do this from AMI.

Very tied up on other projects, but if another developer wanted to look into adding support for it, I believe it would be something along these lines….


int action_hold(struct mansession *s, const struct message *m)
{
    const char *channelarg = astman_get_header(m, "Channel");
    struct ast_channel *chan = NULL;
    int res = -1;

    if (ast_strlen_zero(channelarg))
    {
        astman_send_error(s, m, "No channel specified");
        return 0;
    }

    chan = ast_channel_get_by_name(channelarg);
    if (chan)
    {
        ast_log(LOG_DEBUG, "Putting channel %s on hold (0x%p)\n", ast_channel_name(chan), chan);
        if ((res = ast_indicate(chan, AST_CONTROL_HOLD)))
        {
            astman_send_error(s, m, "Failed to put channel on hold");
        }
        ast_channel_unref(chan);
    }
    else astman_send_error(s, m, "No such channel");

    if (!res) astman_send_ack(s, m, "Hold");

    return 0;
}

int action_unhold(struct mansession *s, const struct message *m)
{
    const char *channelarg = astman_get_header(m, "Channel");
    struct ast_channel *chan = NULL;
    int res = -1;

    if (ast_strlen_zero(channelarg))
    {
        astman_send_error(s, m, "No channel specified");
        return 0;
    }

    chan = ast_channel_get_by_name(channelarg);
    if (chan)
    {
        if ((res = ast_indicate(chan, AST_CONTROL_UNHOLD)))
        {
            astman_send_error(s, m, "Failed to remove channel from hold");
        }
        ast_channel_unref(chan);
    }
    else astman_send_error(s, m, "No such channel");

    if (!res) astman_send_ack(s, m, "Unhold");

    return 0;
}

const char *hold_synopsis = "Place Channel on Hold";
const char *hold_desc = "Place the channel specified by the 'Channel' argument on Hold";
const char *unhold_synopsis = "Remove Channel from Hold";
const char *unhold_desc = "Remove the channel specified by the 'Channel' argument from Hold";

ast_manager_register2("Hold", EVENT_FLAG_CALL, action_hold, AST_MODULE_SELF, hold_synopsis, hold_desc);
ast_manager_register2("UnHold", EVENT_FLAG_CALL, action_unhold, AST_MODULE_SELF, unhold_synopsis, unhold_desc);


From: asterisk-users <asterisk-users-bounces at lists.digium.com> On Behalf Of Joshua C. Colp
Sent: Wednesday, July 21, 2021 5:57 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion <asterisk-users at lists.digium.com>
Subject: Re: [asterisk-users] Call Hold / Transfer via AMI

On Wed, Jul 21, 2021 at 7:39 AM Antony Stone <Antony.Stone at asterisk.open.source.it<mailto:Antony.Stone at asterisk.open.source.it>> wrote:
Hi.

From the lack of response to my question, I'm assuming that either:

a) putting a call on hold is not possible via AMI
or
b) everyone thinks it's so obvious that I should be able to see it for myself

Can anyone confirm one way or the other?

If it simply isn't possible, I'd like to put my efforts into exploring
alternative solutions instead of spending more time on AMI.

From a surface level I know of no way from AMI to control putting a call on and off hold.

--
Joshua C. Colp
Asterisk Technical Lead
Sangoma Technologies
Check us out at www.sangoma.com<http://www.sangoma.com> and www.asterisk.org<http://www.asterisk.org>

This email is intended only for the use of the party to which it is addressed and may contain information that is privileged, confidential, or protected by law. If you are not the intended recipient you are hereby notified that any dissemination, copying or distribution of this email or its contents is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20210721/edae85fe/attachment.html>


More information about the asterisk-users mailing list