2013-04-08 13:27:45 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 - 2013, Digium, Inc.
|
|
|
|
*
|
|
|
|
* David M. Lee, II <dlee@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2013-04-15 16:43:47 +00:00
|
|
|
#ifndef _ASTERISK_STASIS_APP_H
|
|
|
|
#define _ASTERISK_STASIS_APP_H
|
2013-04-08 13:27:45 +00:00
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
2013-04-15 16:43:47 +00:00
|
|
|
* \brief Stasis Application API. See \ref res_stasis "Stasis Application API"
|
2013-04-08 13:27:45 +00:00
|
|
|
* for detailed documentation.
|
|
|
|
*
|
|
|
|
* \author David M. Lee, II <dlee@digium.com>
|
|
|
|
* \since 12
|
|
|
|
*
|
2013-04-15 16:43:47 +00:00
|
|
|
* \page res_stasis Stasis Application API
|
2013-04-08 13:27:45 +00:00
|
|
|
*
|
|
|
|
* This is the API that binds the Stasis dialplan application to external
|
|
|
|
* Stasis applications, such as \c res_stasis_websocket.
|
|
|
|
*
|
2013-04-15 16:43:47 +00:00
|
|
|
* The associated \c res_stasis module registers a dialplan function named \c
|
|
|
|
* Stasis, which uses \c res_stasis to put a channel into the named Stasis
|
|
|
|
* app. As a channel enters and leaves the Stasis diaplan application, the
|
|
|
|
* Stasis app receives a \c 'stasis-start' and \c 'stasis-end' events.
|
2013-04-08 13:27:45 +00:00
|
|
|
*
|
|
|
|
* Stasis apps register themselves using the \ref stasis_app_register and
|
|
|
|
* stasis_app_unregister functions. Messages are sent to an appliction using
|
|
|
|
* \ref stasis_app_send.
|
|
|
|
*
|
|
|
|
* Finally, Stasis apps control channels through the use of the \ref
|
|
|
|
* stasis_app_control object, and the family of \c stasis_app_control_*
|
|
|
|
* functions.
|
2013-05-10 17:12:57 +00:00
|
|
|
*
|
|
|
|
* Since module unload order is based on reference counting, any module that
|
2017-12-29 03:57:17 -05:00
|
|
|
* uses the API defined in this file must list "res_stasis" in the requires
|
|
|
|
* field.
|
2013-04-08 13:27:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
|
2013-04-15 16:43:47 +00:00
|
|
|
/*! @{ */
|
|
|
|
|
2013-04-08 13:27:45 +00:00
|
|
|
/*!
|
|
|
|
* \brief Callback for Stasis application handler.
|
|
|
|
*
|
|
|
|
* The message given to the handler is a borrowed copy. If you want to keep a
|
|
|
|
* reference to it, you should use \c ao2_ref() to keep it around.
|
|
|
|
*
|
|
|
|
* \param data Data ptr given when registered.
|
|
|
|
* \param app_name Name of the application being dispatched to.
|
|
|
|
* \param message Message to handle. (borrowed copy)
|
|
|
|
*/
|
|
|
|
typedef void (*stasis_app_cb)(void *data, const char *app_name,
|
2013-05-14 21:45:08 +00:00
|
|
|
struct ast_json *message);
|
2013-04-08 13:27:45 +00:00
|
|
|
|
2013-10-04 16:01:48 +00:00
|
|
|
/*!
|
|
|
|
* \brief Gets the names of all registered Stasis applications.
|
|
|
|
*
|
|
|
|
* \return \c ast_str_container of container names.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL on error.
|
2013-10-04 16:01:48 +00:00
|
|
|
*/
|
|
|
|
struct ao2_container *stasis_app_get_all(void);
|
|
|
|
|
2016-10-20 07:27:21 -05:00
|
|
|
/*!
|
|
|
|
* \brief Retrieve a handle to a Stasis application by its name
|
|
|
|
*
|
|
|
|
* \param name The name of the registered Stasis application
|
|
|
|
*
|
|
|
|
* \return \c stasis_app on success.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL on error.
|
2016-10-20 07:27:21 -05:00
|
|
|
*/
|
|
|
|
struct stasis_app *stasis_app_get_by_name(const char *name);
|
|
|
|
|
2025-04-16 13:40:52 -06:00
|
|
|
/*!
|
|
|
|
* \brief Check if a Stasis application is registered.
|
|
|
|
*
|
|
|
|
* \param name The name of the registered Stasis application
|
|
|
|
*
|
|
|
|
* \return 1 if the application is registered.
|
|
|
|
* \return 0 if the application is not registered.
|
|
|
|
*/
|
|
|
|
int stasis_app_is_registered(const char *name);
|
|
|
|
|
2013-04-08 13:27:45 +00:00
|
|
|
/*!
|
|
|
|
* \brief Register a new Stasis application.
|
|
|
|
*
|
|
|
|
* If an application is already registered with the given name, the old
|
|
|
|
* application is sent a 'replaced' message and unregistered.
|
|
|
|
*
|
|
|
|
* \param app_name Name of this application.
|
|
|
|
* \param handler Callback for application messages.
|
|
|
|
* \param data Data blob to pass to the callback. Must be AO2 managed.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-04-08 13:27:45 +00:00
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data);
|
|
|
|
|
2015-09-04 12:25:07 -05:00
|
|
|
/*!
|
|
|
|
* \brief Register a new Stasis application that receives all Asterisk events.
|
|
|
|
*
|
|
|
|
* If an application is already registered with the given name, the old
|
|
|
|
* application is sent a 'replaced' message and unregistered.
|
|
|
|
*
|
|
|
|
* \param app_name Name of this application.
|
|
|
|
* \param handler Callback for application messages.
|
|
|
|
* \param data Data blob to pass to the callback. Must be AO2 managed.
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_register_all(const char *app_name, stasis_app_cb handler, void *data);
|
|
|
|
|
2013-04-08 13:27:45 +00:00
|
|
|
/*!
|
2025-04-16 13:40:52 -06:00
|
|
|
* \brief Unregister a Stasis application and unsubscribe from all event sources.
|
2013-04-08 13:27:45 +00:00
|
|
|
* \param app_name Name of the application to unregister.
|
|
|
|
*/
|
|
|
|
void stasis_app_unregister(const char *app_name);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Send a message to the given Stasis application.
|
|
|
|
*
|
|
|
|
* The message given to the handler is a borrowed copy. If you want to keep a
|
|
|
|
* reference to it, you should use \c ao2_ref() to keep it around.
|
|
|
|
*
|
|
|
|
* \param app_name Name of the application to invoke.
|
|
|
|
* \param message Message to send (borrowed reference)
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-04-08 13:27:45 +00:00
|
|
|
* \return 0 for success.
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_send(const char *app_name, struct ast_json *message);
|
|
|
|
|
2013-11-23 17:48:28 +00:00
|
|
|
/*! \brief Forward declare app */
|
|
|
|
struct stasis_app;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Retrieve an application's name
|
|
|
|
*
|
|
|
|
* \param app An application
|
|
|
|
*
|
|
|
|
* \return The name of the application.
|
|
|
|
*/
|
|
|
|
const char *stasis_app_name(const struct stasis_app *app);
|
|
|
|
|
2019-02-08 14:48:27 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the JSON representation of a Stasis application.
|
|
|
|
* \since 16.3.0
|
|
|
|
*
|
|
|
|
* \param app The application.
|
|
|
|
*
|
|
|
|
* \return JSON representation of app with given name.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL on error.
|
2019-02-08 14:48:27 -06:00
|
|
|
*/
|
|
|
|
struct ast_json *stasis_app_object_to_json(struct stasis_app *app);
|
|
|
|
|
2013-10-04 16:01:48 +00:00
|
|
|
/*!
|
|
|
|
* \brief Return the JSON representation of a Stasis application.
|
|
|
|
*
|
|
|
|
* \param app_name Name of the application.
|
|
|
|
*
|
|
|
|
* \return JSON representation of app with given name.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL on error.
|
2013-10-04 16:01:48 +00:00
|
|
|
*/
|
|
|
|
struct ast_json *stasis_app_to_json(const char *app_name);
|
|
|
|
|
2013-11-23 17:48:28 +00:00
|
|
|
/*!
|
|
|
|
* \brief Event source information and callbacks.
|
|
|
|
*/
|
|
|
|
struct stasis_app_event_source {
|
|
|
|
/*! \brief The scheme to match against on [un]subscribes */
|
|
|
|
const char *scheme;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Find an event source data object by the given id/name.
|
|
|
|
*
|
|
|
|
* \param app Application
|
|
|
|
* \param id A unique identifier to search on
|
|
|
|
*
|
|
|
|
* \return The data object associated with the id/name.
|
|
|
|
*/
|
|
|
|
void *(*find)(const struct stasis_app *app, const char *id);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Subscribe an application to an event source.
|
|
|
|
*
|
|
|
|
* \param app Application
|
|
|
|
* \param obj an event source data object
|
|
|
|
*
|
|
|
|
* \return 0 on success, failure code otherwise
|
|
|
|
*/
|
|
|
|
int (*subscribe)(struct stasis_app *app, void *obj);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Cancel the subscription an app has to an event source.
|
|
|
|
*
|
|
|
|
* \param app Application
|
|
|
|
* \param id a previously subscribed object id
|
|
|
|
*
|
|
|
|
* \return 0 on success, failure code otherwise
|
|
|
|
*/
|
|
|
|
int (*unsubscribe)(struct stasis_app *app, const char *id);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Find an event source by the given id/name.
|
|
|
|
*
|
|
|
|
* \param app Application
|
|
|
|
* \param id A unique identifier to check
|
|
|
|
*
|
|
|
|
* \return true if id is subscribed, false otherwise.
|
|
|
|
*/
|
|
|
|
int (*is_subscribed)(struct stasis_app *app, const char *id);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Convert event source data to json
|
|
|
|
*
|
|
|
|
* \param app Application
|
|
|
|
* \param id json object to fill
|
|
|
|
*/
|
|
|
|
void (*to_json)(const struct stasis_app *app, struct ast_json *json);
|
|
|
|
|
|
|
|
/*! Next item in the list */
|
|
|
|
AST_LIST_ENTRY(stasis_app_event_source) next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Register an application event source.
|
|
|
|
*
|
|
|
|
* \param obj the event source to register
|
|
|
|
*/
|
|
|
|
void stasis_app_register_event_source(struct stasis_app_event_source *obj);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Register core event sources.
|
|
|
|
*/
|
|
|
|
void stasis_app_register_event_sources(void);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unregister an application event source.
|
|
|
|
*
|
|
|
|
* \param obj the event source to unregister
|
|
|
|
*/
|
|
|
|
void stasis_app_unregister_event_source(struct stasis_app_event_source *obj);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unregister core event sources.
|
|
|
|
*/
|
|
|
|
void stasis_app_unregister_event_sources(void);
|
|
|
|
|
2014-05-22 16:09:51 +00:00
|
|
|
/*! \brief Return code for stasis_app_user_event */
|
|
|
|
enum stasis_app_user_event_res {
|
|
|
|
STASIS_APP_USER_OK,
|
|
|
|
STASIS_APP_USER_APP_NOT_FOUND,
|
|
|
|
STASIS_APP_USER_EVENT_SOURCE_NOT_FOUND,
|
|
|
|
STASIS_APP_USER_EVENT_SOURCE_BAD_SCHEME,
|
|
|
|
STASIS_APP_USER_USEREVENT_INVALID,
|
|
|
|
STASIS_APP_USER_INTERNAL_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Generate a Userevent for stasis app (echo to AMI)
|
|
|
|
*
|
|
|
|
* \param app_name Name of the application to generate event for/to.
|
|
|
|
* \param event_name Name of the Userevent.
|
|
|
|
* \param source_uris URIs for the source objects to attach to event.
|
|
|
|
* \param sources_count Array size of source_uris.
|
2015-01-23 15:21:56 +00:00
|
|
|
* \param json_variables event blob variables.
|
2014-05-22 16:09:51 +00:00
|
|
|
*
|
|
|
|
* \return \ref stasis_app_user_event_res return code.
|
|
|
|
*/
|
|
|
|
enum stasis_app_user_event_res stasis_app_user_event(const char *app_name,
|
|
|
|
const char *event_name,
|
|
|
|
const char **source_uris, int sources_count,
|
|
|
|
struct ast_json *json_variables);
|
|
|
|
|
2013-11-23 17:48:28 +00:00
|
|
|
|
2013-10-04 16:01:48 +00:00
|
|
|
/*! \brief Return code for stasis_app_[un]subscribe */
|
|
|
|
enum stasis_app_subscribe_res {
|
|
|
|
STASIS_ASR_OK,
|
|
|
|
STASIS_ASR_APP_NOT_FOUND,
|
|
|
|
STASIS_ASR_EVENT_SOURCE_NOT_FOUND,
|
|
|
|
STASIS_ASR_EVENT_SOURCE_BAD_SCHEME,
|
|
|
|
STASIS_ASR_INTERNAL_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Subscribes an application to a list of event sources.
|
|
|
|
*
|
|
|
|
* \param app_name Name of the application to subscribe.
|
|
|
|
* \param event_source_uris URIs for the event sources to subscribe to.
|
|
|
|
* \param event_sources_count Array size of event_source_uris.
|
|
|
|
* \param json Optional output pointer for JSON representation of the app
|
|
|
|
* after adding the subscription.
|
|
|
|
*
|
|
|
|
* \return \ref stasis_app_subscribe_res return code.
|
2013-11-01 12:33:09 +00:00
|
|
|
*
|
|
|
|
* \note Do not hold any channel locks if subscribing to a channel.
|
2013-10-04 16:01:48 +00:00
|
|
|
*/
|
|
|
|
enum stasis_app_subscribe_res stasis_app_subscribe(const char *app_name,
|
|
|
|
const char **event_source_uris, int event_sources_count,
|
|
|
|
struct ast_json **json);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unsubscribes an application from a list of event sources.
|
|
|
|
*
|
|
|
|
* \param app_name Name of the application to subscribe.
|
|
|
|
* \param event_source_uris URIs for the event sources to subscribe to.
|
|
|
|
* \param event_sources_count Array size of event_source_uris.
|
|
|
|
* \param json Optional output pointer for JSON representation of the app
|
|
|
|
* after adding the subscription.
|
|
|
|
*
|
|
|
|
* \return \ref stasis_app_subscribe_res return code.
|
|
|
|
*/
|
|
|
|
enum stasis_app_subscribe_res stasis_app_unsubscribe(const char *app_name,
|
|
|
|
const char **event_source_uris, int event_sources_count,
|
|
|
|
struct ast_json **json);
|
|
|
|
|
ARI/res_stasis: Subscribe to both Local channel halves when originating to app
This patch fixes two bugs:
1. When originating a channel into a Stasis application, we already create a
subscription for the channel that is going into our Stasis app.
Unfortunately, when you create a Local channel and pass it off to a Stasis
app, you really aren't creating just one channel: you're creating two. This
patch snags the second half of the Local channel pair (assuming it is a
Local channel pair, but luckily core_local is kind about such assumptions)
and subscribes to it as well.
2. Subscriptions are a bit sticky right now. If a subscription is made, the
'interest' count gets bumped on the Stasis subscription - but unless
something explicitly unsubscribes the channel, said subscription sticks
around. This is not much of a problem is a user is creating the subscription
- if they made it, they must want it. However, when we are creating
implicit subscriptions, we need to make sure something clears them out.
This patch takes a pessimistic approach: it watches the cache updates
coming from Stasis and, if we notice that the cache just cleared out an
object, we delete our subscription object. This keeps our ao2 container of
Stasis forwards in an application from growing out of hand; it also is a
bit more forgiving for end users who may not realize they were supposed to
unsubscribe from that channel that just hung up.
Review: https://reviewboard.asterisk.org/r/3710/
#ASTERISK-23939 #close
........
Merged revisions 418089 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418090 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-07 02:15:00 +00:00
|
|
|
/*!
|
|
|
|
* \brief Directly subscribe an application to a channel
|
|
|
|
*
|
|
|
|
* \param app_name Name of the application to subscribe.
|
|
|
|
* \param chan The channel to subscribe to
|
|
|
|
*
|
|
|
|
* \return \ref stasis_app_subscribe_res return code.
|
|
|
|
*
|
|
|
|
* \note This method can be used when you already hold a channel and its
|
|
|
|
* lock. This bypasses the channel lookup that would normally be
|
|
|
|
* performed by \ref stasis_app_subscribe.
|
|
|
|
*/
|
|
|
|
enum stasis_app_subscribe_res stasis_app_subscribe_channel(const char *app_name,
|
|
|
|
struct ast_channel *chan);
|
|
|
|
|
2013-04-08 13:27:45 +00:00
|
|
|
/*! @} */
|
|
|
|
|
|
|
|
/*! @{ */
|
|
|
|
|
|
|
|
/*! \brief Handler for controlling a channel that's in a Stasis application */
|
|
|
|
struct stasis_app_control;
|
|
|
|
|
2013-12-13 16:38:57 +00:00
|
|
|
/*! \brief Rule to check to see if an operation is allowed */
|
|
|
|
struct stasis_app_control_rule {
|
|
|
|
/*!
|
|
|
|
* \brief Checks to see if an operation is allowed on the control
|
|
|
|
*
|
|
|
|
* \param control Control object to check
|
|
|
|
* \return 0 on success, otherwise a failure code
|
|
|
|
*/
|
|
|
|
enum stasis_app_control_channel_result (*check_rule)(
|
|
|
|
const struct stasis_app_control *control);
|
|
|
|
/*! Next item in the list */
|
|
|
|
AST_LIST_ENTRY(stasis_app_control_rule) next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Registers an add channel to bridge rule.
|
|
|
|
*
|
|
|
|
* \param control Control object
|
|
|
|
* \param rule The rule to register
|
|
|
|
*/
|
|
|
|
void stasis_app_control_register_add_rule(
|
|
|
|
struct stasis_app_control *control,
|
|
|
|
struct stasis_app_control_rule *rule);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief UnRegister an add channel to bridge rule.
|
|
|
|
*
|
|
|
|
* \param control Control object
|
|
|
|
* \param rule The rule to unregister
|
|
|
|
*/
|
|
|
|
void stasis_app_control_unregister_add_rule(
|
|
|
|
struct stasis_app_control *control,
|
|
|
|
struct stasis_app_control_rule *rule);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Registers a remove channel from bridge rule.
|
|
|
|
*
|
|
|
|
* \param control Control object
|
|
|
|
* \param rule The rule to register
|
|
|
|
*/
|
|
|
|
void stasis_app_control_register_remove_rule(
|
|
|
|
struct stasis_app_control *control,
|
|
|
|
struct stasis_app_control_rule *rule);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unregisters a remove channel from bridge rule.
|
|
|
|
*
|
|
|
|
* \param control Control object
|
|
|
|
* \param rule The rule to unregister
|
|
|
|
*/
|
|
|
|
void stasis_app_control_unregister_remove_rule(
|
|
|
|
struct stasis_app_control *control,
|
|
|
|
struct stasis_app_control_rule *rule);
|
|
|
|
|
2013-04-08 13:27:45 +00:00
|
|
|
/*!
|
2013-04-22 14:58:53 +00:00
|
|
|
* \brief Returns the handler for the given channel.
|
2013-04-08 13:27:45 +00:00
|
|
|
* \param chan Channel to handle.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-04-22 14:58:53 +00:00
|
|
|
* \return NULL channel not in Stasis application.
|
|
|
|
* \return Pointer to \c res_stasis handler.
|
2013-04-08 13:27:45 +00:00
|
|
|
*/
|
|
|
|
struct stasis_app_control *stasis_app_control_find_by_channel(
|
|
|
|
const struct ast_channel *chan);
|
|
|
|
|
|
|
|
/*!
|
2013-04-22 14:58:53 +00:00
|
|
|
* \brief Returns the handler for the channel with the given id.
|
|
|
|
* \param channel_id Uniqueid of the channel.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-04-22 14:58:53 +00:00
|
|
|
* \return NULL channel not in Stasis application, or channel does not exist.
|
|
|
|
* \return Pointer to \c res_stasis handler.
|
|
|
|
*/
|
|
|
|
struct stasis_app_control *stasis_app_control_find_by_channel_id(
|
|
|
|
const char *channel_id);
|
|
|
|
|
2013-07-19 19:35:21 +00:00
|
|
|
/*!
|
|
|
|
* \brief Creates a control handler for a channel that isn't in a stasis app.
|
|
|
|
* \since 12.0.0
|
|
|
|
*
|
|
|
|
* \param chan Channel to create controller handle for
|
|
|
|
*
|
|
|
|
* \return NULL on failure to create the handle
|
|
|
|
* \return Pointer to \c res_stasis handler.
|
|
|
|
*/
|
|
|
|
struct stasis_app_control *stasis_app_control_create(
|
|
|
|
struct ast_channel *chan);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Act on a stasis app control queue until it is empty
|
|
|
|
* \since 12.0.0
|
|
|
|
*
|
|
|
|
* \param chan Channel to handle
|
|
|
|
* \param control Control object to execute
|
|
|
|
*/
|
|
|
|
void stasis_app_control_execute_until_exhausted(
|
|
|
|
struct ast_channel *chan,
|
|
|
|
struct stasis_app_control *control);
|
|
|
|
|
2014-04-18 20:09:24 +00:00
|
|
|
/*!
|
|
|
|
* \brief Check if a control is marked as done
|
|
|
|
* \since 12.2.0
|
|
|
|
*
|
|
|
|
* \param control Which control object is being evaluated
|
|
|
|
*/
|
|
|
|
int stasis_app_control_is_done(
|
|
|
|
struct stasis_app_control *control);
|
|
|
|
|
2025-04-16 13:40:52 -06:00
|
|
|
/*!
|
|
|
|
* \brief Set the failed flag on a control structure
|
|
|
|
*
|
|
|
|
* \param control Control object to be updated
|
|
|
|
*/
|
|
|
|
void stasis_app_control_mark_failed(struct stasis_app_control *control);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Check if a control object is marked as "failed"
|
|
|
|
*
|
|
|
|
* \param control Control object to check
|
|
|
|
*/
|
|
|
|
int stasis_app_control_is_failed(const struct stasis_app_control *control);
|
|
|
|
|
2016-03-29 13:47:08 -05:00
|
|
|
/*!
|
|
|
|
* \brief Flush the control command queue.
|
|
|
|
* \since 13.9.0
|
|
|
|
*
|
|
|
|
* \param control Control object to flush command queue.
|
|
|
|
*/
|
|
|
|
void stasis_app_control_flush_queue(struct stasis_app_control *control);
|
|
|
|
|
2013-05-14 21:45:08 +00:00
|
|
|
/*!
|
|
|
|
* \brief Returns the uniqueid of the channel associated with this control
|
|
|
|
*
|
|
|
|
* \param control Control object.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-05-14 21:45:08 +00:00
|
|
|
* \return Uniqueid of the associate channel.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL if \a control is \c NULL.
|
2013-05-14 21:45:08 +00:00
|
|
|
*/
|
|
|
|
const char *stasis_app_control_get_channel_id(
|
|
|
|
const struct stasis_app_control *control);
|
|
|
|
|
2013-08-05 16:59:13 +00:00
|
|
|
/*!
|
|
|
|
* \brief Apply a bridge role to a channel controlled by a stasis app control
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis
|
|
|
|
* \param role Role to apply
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_add_role(struct stasis_app_control *control, const char *role);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Clear bridge roles currently applied to a channel controlled by a stasis app control
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis
|
|
|
|
*/
|
|
|
|
void stasis_app_control_clear_roles(struct stasis_app_control *control);
|
|
|
|
|
2013-04-22 14:58:53 +00:00
|
|
|
/*!
|
|
|
|
* \brief Exit \c res_stasis and continue execution in the dialplan.
|
2013-04-08 13:27:45 +00:00
|
|
|
*
|
2013-04-22 14:58:53 +00:00
|
|
|
* If the channel is no longer in \c res_stasis, this function does nothing.
|
2013-04-08 13:27:45 +00:00
|
|
|
*
|
2013-04-22 14:58:53 +00:00
|
|
|
* \param control Control for \c res_stasis
|
2013-06-26 19:29:57 +00:00
|
|
|
* \param context An optional context to continue to
|
|
|
|
* \param extension An optional extension to continue to
|
|
|
|
* \param priority An optional priority to continue to
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error.
|
2013-04-22 14:58:53 +00:00
|
|
|
*/
|
2013-06-26 19:29:57 +00:00
|
|
|
int stasis_app_control_continue(struct stasis_app_control *control, const char *context, const char *extension, int priority);
|
2013-04-22 14:58:53 +00:00
|
|
|
|
2019-03-07 07:52:20 -06:00
|
|
|
/*!
|
|
|
|
* \brief Exit \c res_stasis and move to another Stasis application.
|
|
|
|
*
|
|
|
|
* If the channel is no longer in \c res_stasis, this function does nothing.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis
|
|
|
|
* \param app_name The name of the application to switch to
|
|
|
|
* \param app_args The list of arguments to pass to the application
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error
|
|
|
|
*/
|
|
|
|
int stasis_app_control_move(struct stasis_app_control *control, const char *app_name, const char *app_args);
|
|
|
|
|
ARI/PJSIP: Add the ability to redirect (transfer) a channel in a Stasis app
This patch adds a new feature to ARI to redirect a channel to another server,
and fixes a few bugs in PJSIP's handling of the Transfer dialplan
application/ARI redirect capability.
*New Feature*
A new operation has been added to the ARI channels resource, redirect. With
this, a channel in a Stasis application can be redirected to another endpoint
of the same underlying channel technology.
*Bug fixes*
In the process of writing this new feature, two bugs were fixed in the PJSIP
stack:
(1) The existing .transfer channel callback had the limitation that it could
only transfer channels to a SIP URI, i.e., you had to pass
'PJSIP/sip:foo@my_provider.com' to the dialplan application. While this is
still supported, it is somewhat unintuitive - particularly in a world full
of endpoints. As such, we now also support specifying the PJSIP endpoint to
transfer to.
(2) res_pjsip_multihomed was, unfortunately, trying to 'help' a 302 redirect by
updating its Contact header. Alas, that resulted in the forwarding
destination set by the dialplan application/ARI resource/whatever being
rewritten with very incorrect information. Hence, we now don't bother
updating an outgoing response if it is a 302. Since this took a looong time
to find, some additional debug statements have been added to those modules
that update the Contact headers.
Review: https://reviewboard.asterisk.org/r/4316/
ASTERISK-24015 #close
Reported by: Private Name
ASTERISK-24703 #close
Reported by: Matt Jordan
........
Merged revisions 431717 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431718 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-12 20:34:37 +00:00
|
|
|
/*!
|
|
|
|
* \brief Redirect a channel in \c res_stasis to a particular endpoint
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis
|
|
|
|
* \param endpoint The endpoint transfer string where the channel should be sent to
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error
|
|
|
|
*/
|
|
|
|
int stasis_app_control_redirect(struct stasis_app_control *control, const char *endpoint);
|
|
|
|
|
2013-11-01 14:38:21 +00:00
|
|
|
/*!
|
|
|
|
* \brief Indicate ringing to the channel associated with this control.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_ring(struct stasis_app_control *control);
|
|
|
|
|
2013-11-13 23:11:32 +00:00
|
|
|
/*!
|
|
|
|
* \brief Stop locally generated ringing on the channel associated with this control.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_ring_stop(struct stasis_app_control *control);
|
|
|
|
|
2025-07-30 14:24:07 +02:00
|
|
|
/*!
|
|
|
|
* \brief Indicate progress to the channel associated with this control.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_progress(struct stasis_app_control *control);
|
|
|
|
|
2013-11-01 14:38:21 +00:00
|
|
|
/*!
|
|
|
|
* \brief Send DTMF to the channel associated with this control.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
* \param dtmf DTMF string.
|
|
|
|
* \param before Amount of time to wait before sending DTMF digits.
|
|
|
|
* \param between Amount of time between each DTMF digit.
|
|
|
|
* \param duration Amount of time each DTMF digit lasts for.
|
|
|
|
* \param after Amount of time to wait after sending DTMF digits.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_dtmf(struct stasis_app_control *control, const char *dtmf, int before, int between, unsigned int duration, int after);
|
|
|
|
|
2013-07-18 16:03:12 +00:00
|
|
|
/*!
|
|
|
|
* \brief Mute the channel associated with this control.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
* \param direction The direction in which the audio should be muted.
|
|
|
|
* \param frametype The type of stream that should be muted.
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_mute(struct stasis_app_control *control, unsigned int direction, enum ast_frame_type frametype);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unmute the channel associated with this control.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
* \param direction The direction in which the audio should be unmuted.
|
|
|
|
* \param frametype The type of stream that should be unmuted.
|
|
|
|
*
|
|
|
|
* \return 0 for success
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_unmute(struct stasis_app_control *control, unsigned int direction, enum ast_frame_type frametype);
|
|
|
|
|
2013-04-22 14:58:53 +00:00
|
|
|
/*!
|
|
|
|
* \brief Answer the channel associated with this control.
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
* \return 0 for success.
|
2013-05-14 21:45:08 +00:00
|
|
|
* \return Non-zero for error.
|
2013-04-22 14:58:53 +00:00
|
|
|
*/
|
|
|
|
int stasis_app_control_answer(struct stasis_app_control *control);
|
|
|
|
|
2013-07-08 14:46:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief Set a variable on the channel associated with this control to value.
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
* \param variable The name of the variable
|
|
|
|
* \param value The value to set the variable to
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -1 for error.
|
|
|
|
*/
|
|
|
|
int stasis_app_control_set_channel_var(struct stasis_app_control *control, const char *variable, const char *value);
|
|
|
|
|
2013-07-01 18:56:21 +00:00
|
|
|
/*!
|
|
|
|
* \brief Place the channel associated with the control on hold.
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*/
|
|
|
|
void stasis_app_control_hold(struct stasis_app_control *control);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Remove the channel associated with the control from hold.
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*/
|
|
|
|
void stasis_app_control_unhold(struct stasis_app_control *control);
|
|
|
|
|
2013-07-19 19:40:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief Play music on hold to a channel (does not affect hold status)
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
* \param moh_class class of music on hold to play (NULL allowed)
|
|
|
|
*/
|
|
|
|
void stasis_app_control_moh_start(struct stasis_app_control *control, const char *moh_class);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Stop playing music on hold to a channel (does not affect hold status)
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*/
|
|
|
|
void stasis_app_control_moh_stop(struct stasis_app_control *control);
|
|
|
|
|
2013-11-21 15:56:34 +00:00
|
|
|
/*!
|
|
|
|
* \brief Start playing silence to a channel.
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*/
|
|
|
|
void stasis_app_control_silence_start(struct stasis_app_control *control);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Stop playing silence to a channel.
|
|
|
|
* \param control Control for \c res_stasis.
|
|
|
|
*/
|
|
|
|
void stasis_app_control_silence_stop(struct stasis_app_control *control);
|
|
|
|
|
2013-05-14 21:45:08 +00:00
|
|
|
/*!
|
|
|
|
* \brief Returns the most recent snapshot for the associated channel.
|
|
|
|
*
|
|
|
|
* The returned pointer is AO2 managed, so ao2_cleanup() when you're done.
|
|
|
|
*
|
|
|
|
* \param control Control for \c res_stasis.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-05-14 21:45:08 +00:00
|
|
|
* \return Most recent snapshot. ao2_cleanup() when done.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL if channel isn't in cache.
|
2013-05-14 21:45:08 +00:00
|
|
|
*/
|
|
|
|
struct ast_channel_snapshot *stasis_app_control_get_snapshot(
|
|
|
|
const struct stasis_app_control *control);
|
2013-04-22 14:58:53 +00:00
|
|
|
|
|
|
|
/*!
|
2013-05-14 21:45:08 +00:00
|
|
|
* \brief Publish a message to the \a control's channel's topic.
|
|
|
|
*
|
|
|
|
* \param control Control to publish to
|
|
|
|
* \param message Message to publish
|
2013-04-08 13:27:45 +00:00
|
|
|
*/
|
2013-05-14 21:45:08 +00:00
|
|
|
void stasis_app_control_publish(
|
|
|
|
struct stasis_app_control *control, struct stasis_message *message);
|
2013-04-08 13:27:45 +00:00
|
|
|
|
2014-05-22 16:09:51 +00:00
|
|
|
/*!
|
|
|
|
* \brief Returns the stasis topic for an app
|
|
|
|
*
|
|
|
|
* \param app Stasis app to get topic of
|
|
|
|
*/
|
|
|
|
struct stasis_topic *ast_app_get_topic(struct stasis_app *app);
|
|
|
|
|
2013-05-23 20:21:16 +00:00
|
|
|
/*!
|
|
|
|
* \brief Queue a control frame without payload.
|
|
|
|
*
|
|
|
|
* \param control Control to publish to.
|
|
|
|
* \param frame_type type of control frame.
|
|
|
|
*
|
|
|
|
* \return zero on success
|
|
|
|
* \return non-zero on failure
|
|
|
|
*/
|
|
|
|
int stasis_app_control_queue_control(struct stasis_app_control *control,
|
|
|
|
enum ast_control_frame_type frame_type);
|
|
|
|
|
2013-06-10 13:07:11 +00:00
|
|
|
/*!
|
|
|
|
* \brief Create a bridge of the specified type.
|
|
|
|
*
|
|
|
|
* \param type The type of bridge to be created
|
2013-12-17 23:25:49 +00:00
|
|
|
* \param name Optional name to give to the bridge
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
* \param id Optional Unique ID to give to the bridge
|
2013-06-10 13:07:11 +00:00
|
|
|
*
|
|
|
|
* \return New bridge.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL on error.
|
2013-06-10 13:07:11 +00:00
|
|
|
*/
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
struct ast_bridge *stasis_app_bridge_create(const char *type, const char *name, const char *id);
|
2013-06-10 13:07:11 +00:00
|
|
|
|
2016-05-09 14:48:51 -05:00
|
|
|
/*!
|
|
|
|
* \brief Create an invisible bridge of the specified type.
|
|
|
|
*
|
|
|
|
* \param type The type of bridge to be created
|
|
|
|
* \param name Optional name to give to the bridge
|
|
|
|
* \param id Optional Unique ID to give to the bridge
|
|
|
|
*
|
|
|
|
* \return New bridge.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL on error.
|
2016-05-09 14:48:51 -05:00
|
|
|
*/
|
|
|
|
struct ast_bridge *stasis_app_bridge_create_invisible(const char *type, const char *name, const char *id);
|
|
|
|
|
2013-06-10 13:07:11 +00:00
|
|
|
/*!
|
|
|
|
* \brief Returns the bridge with the given id.
|
|
|
|
* \param bridge_id Uniqueid of the bridge.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-06-10 13:07:11 +00:00
|
|
|
* \return NULL bridge not created by a Stasis application, or bridge does not exist.
|
|
|
|
* \return Pointer to bridge.
|
|
|
|
*/
|
|
|
|
struct ast_bridge *stasis_app_bridge_find_by_id(
|
|
|
|
const char *bridge_id);
|
|
|
|
|
2013-08-23 00:26:19 +00:00
|
|
|
/*!
|
|
|
|
* \brief Finds or creates an announcer channel in a bridge that can play music on hold.
|
|
|
|
*
|
|
|
|
* \param bridge Bridge we want an MOH channel for
|
|
|
|
*
|
|
|
|
* \return NULL if the music on hold channel fails to be created or join the bridge for any reason.
|
|
|
|
* \return Pointer to the ;1 end of the announcer channel chain.
|
|
|
|
*/
|
|
|
|
struct ast_channel *stasis_app_bridge_moh_channel(
|
|
|
|
struct ast_bridge *bridge);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Breaks down MOH channels playing on the bridge created by stasis_app_bridge_moh_channel
|
|
|
|
*
|
|
|
|
* \param bridge Bridge we want to stop the MOH on
|
|
|
|
*
|
|
|
|
* \return -1 if no moh channel could be found and stopped
|
|
|
|
* \return 0 on success
|
|
|
|
*/
|
|
|
|
int stasis_app_bridge_moh_stop(
|
|
|
|
struct ast_bridge *bridge);
|
|
|
|
|
2014-04-18 20:09:24 +00:00
|
|
|
/*!
|
|
|
|
* \brief Finds an existing ARI playback channel in a bridge
|
|
|
|
*
|
|
|
|
* \param bridge Bridge we want to find the playback channel for
|
|
|
|
*
|
|
|
|
* \return NULL if the playback channel can not be found for any reason.
|
|
|
|
* \return Pointer to the ;1 end of the playback channel chain.
|
|
|
|
*/
|
|
|
|
struct ast_channel *stasis_app_bridge_playback_channel_find(
|
|
|
|
struct ast_bridge *bridge);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Adds a channel to the list of ARI playback channels for bridges.
|
|
|
|
*
|
|
|
|
* \param bridge Bridge we are adding the playback channel for
|
|
|
|
* \param chan Channel being added as a playback channel (must be ;1)
|
2021-11-16 17:26:23 +01:00
|
|
|
* \param control The app control structure for the playback channel
|
2014-04-18 20:09:24 +00:00
|
|
|
*
|
|
|
|
* \retval -1 failed to add channel for any reason
|
|
|
|
* \retval 0 on success
|
|
|
|
*/
|
|
|
|
int stasis_app_bridge_playback_channel_add(struct ast_bridge *bridge,
|
|
|
|
struct ast_channel *chan,
|
|
|
|
struct stasis_app_control *control);
|
|
|
|
|
2016-06-13 17:40:07 -05:00
|
|
|
/*!
|
|
|
|
* \brief remove channel from list of ARI playback channels for bridges.
|
|
|
|
*
|
|
|
|
* \param bridge_id The unique ID of the bridge the playback channel is in.
|
|
|
|
* \param control The app control structure for the playback channel
|
|
|
|
*/
|
|
|
|
void stasis_app_bridge_playback_channel_remove(char *bridge_id,
|
|
|
|
struct stasis_app_control *control);
|
|
|
|
|
2013-12-13 16:38:57 +00:00
|
|
|
/*!
|
|
|
|
* \brief Result codes used when adding/removing channels to/from bridges.
|
|
|
|
*/
|
|
|
|
enum stasis_app_control_channel_result {
|
|
|
|
/*! The channel is okay to be added/removed */
|
|
|
|
STASIS_APP_CHANNEL_OKAY = 0,
|
|
|
|
/*! The channel is currently recording */
|
|
|
|
STASIS_APP_CHANNEL_RECORDING
|
|
|
|
};
|
|
|
|
|
2013-06-10 13:07:11 +00:00
|
|
|
/*!
|
|
|
|
* \brief Add a channel to the bridge.
|
|
|
|
*
|
|
|
|
* \param control Control whose channel should be added to the bridge
|
|
|
|
* \param bridge Pointer to the bridge
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-08-23 17:19:02 +00:00
|
|
|
* \return non-zero on failure
|
|
|
|
* \return zero on success
|
2013-06-10 13:07:11 +00:00
|
|
|
*/
|
2013-08-23 17:19:02 +00:00
|
|
|
int stasis_app_control_add_channel_to_bridge(
|
2013-06-10 13:07:11 +00:00
|
|
|
struct stasis_app_control *control, struct ast_bridge *bridge);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Remove a channel from the bridge.
|
|
|
|
*
|
|
|
|
* \param control Control whose channel should be removed from the bridge
|
|
|
|
* \param bridge Pointer to the bridge
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-08-23 17:19:02 +00:00
|
|
|
* \return non-zero on failure
|
|
|
|
* \return zero on success
|
2013-06-10 13:07:11 +00:00
|
|
|
*/
|
2013-08-23 17:19:02 +00:00
|
|
|
int stasis_app_control_remove_channel_from_bridge(
|
2013-06-10 13:07:11 +00:00
|
|
|
struct stasis_app_control *control, struct ast_bridge *bridge);
|
|
|
|
|
2017-10-06 21:48:48 -04:00
|
|
|
/*!
|
|
|
|
* \brief Initialize bridge features into a channel control
|
|
|
|
*
|
|
|
|
* \note Bridge features on a control are destroyed after each bridge session,
|
|
|
|
* so new features need to be initialized before each bridge add.
|
|
|
|
*
|
|
|
|
* \param control Control in which to store the features
|
|
|
|
*
|
|
|
|
* \return non-zero on failure
|
|
|
|
* \return zero on success
|
|
|
|
*/
|
|
|
|
int stasis_app_control_bridge_features_init(
|
|
|
|
struct stasis_app_control *control);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Set whether DTMF from the channel is absorbed instead of passing through to the bridge
|
|
|
|
*
|
|
|
|
* \param control Control whose channel should have its DTMF absorbed when bridged
|
|
|
|
* \param absorb Whether DTMF should be absorbed (1) instead of passed through (0).
|
|
|
|
*/
|
|
|
|
void stasis_app_control_absorb_dtmf_in_bridge(
|
|
|
|
struct stasis_app_control *control, int absorb);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Set whether audio from the channel is muted instead of passing through to the bridge
|
|
|
|
*
|
|
|
|
* \param control Control whose channel should have its audio muted when bridged
|
|
|
|
* \param mute Whether audio should be muted (1) instead of passed through (0).
|
|
|
|
*/
|
|
|
|
void stasis_app_control_mute_in_bridge(
|
|
|
|
struct stasis_app_control *control, int mute);
|
|
|
|
|
2019-11-22 15:32:42 +01:00
|
|
|
/*!
|
|
|
|
* \since 18
|
|
|
|
* \brief Set whether COLP frames should be generated when joining the bridge
|
|
|
|
*
|
|
|
|
* \param control Control whose channel should have its COLP frames inhibited when bridged
|
2021-11-16 17:26:23 +01:00
|
|
|
* \param inhibit_colp Whether COLP frames should be generated (0) or not (1).
|
2019-11-22 15:32:42 +01:00
|
|
|
*/
|
|
|
|
void stasis_app_control_inhibit_colp_in_bridge(
|
|
|
|
struct stasis_app_control *control, int inhibit_colp);
|
|
|
|
|
2013-08-23 17:19:02 +00:00
|
|
|
/*!
|
|
|
|
* \since 12
|
|
|
|
* \brief Gets the bridge currently associated with a control object.
|
|
|
|
*
|
2014-04-16 19:14:37 +00:00
|
|
|
* \note If the bridge returned by this function is to be held for any
|
|
|
|
* length of time, its refcount should be incremented until the
|
|
|
|
* caller is finished with it.
|
|
|
|
*
|
2013-08-23 17:19:02 +00:00
|
|
|
* \param control Control object for the channel to query.
|
2013-10-04 16:01:48 +00:00
|
|
|
*
|
2013-08-23 17:19:02 +00:00
|
|
|
* \return Associated \ref ast_bridge.
|
2021-11-16 17:26:23 +01:00
|
|
|
* \retval NULL if not associated with a bridge.
|
2013-08-23 17:19:02 +00:00
|
|
|
*/
|
|
|
|
struct ast_bridge *stasis_app_get_bridge(struct stasis_app_control *control);
|
|
|
|
|
2013-06-10 13:07:11 +00:00
|
|
|
/*!
|
|
|
|
* \brief Destroy the bridge.
|
|
|
|
*
|
|
|
|
* \param bridge_id Uniqueid of bridge to be destroyed
|
|
|
|
*/
|
|
|
|
void stasis_app_bridge_destroy(const char *bridge_id);
|
|
|
|
|
2013-11-22 20:10:46 +00:00
|
|
|
/*!
|
|
|
|
* \brief Get the Stasis message sanitizer for app_stasis applications
|
|
|
|
*
|
|
|
|
* \retval The stasis message sanitizer
|
|
|
|
*/
|
|
|
|
struct stasis_message_sanitizer *stasis_app_get_sanitizer(void);
|
|
|
|
|
2014-08-07 15:30:19 +00:00
|
|
|
/*!
|
|
|
|
* \brief Indicate that this channel has had a StasisEnd published for it
|
|
|
|
*
|
2021-11-16 17:26:23 +01:00
|
|
|
* \param chan The channel that is exiting Stasis.
|
2014-08-07 15:30:19 +00:00
|
|
|
*/
|
|
|
|
void stasis_app_channel_set_stasis_end_published(struct ast_channel *chan);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Has this channel had a StasisEnd published on it?
|
|
|
|
*
|
|
|
|
* \param chan The channel upon which the query rests.
|
|
|
|
*
|
|
|
|
* \retval 0 No
|
|
|
|
* \retval 1 Yes
|
|
|
|
*/
|
|
|
|
int stasis_app_channel_is_stasis_end_published(struct ast_channel *chan);
|
|
|
|
|
2014-08-11 18:38:15 +00:00
|
|
|
/*!
|
|
|
|
* \brief Is this channel internal to Stasis?
|
|
|
|
*
|
|
|
|
* \param chan The channel to check.
|
|
|
|
*
|
|
|
|
* \retval 0 No
|
|
|
|
* \retval 1 Yes
|
|
|
|
*/
|
|
|
|
int stasis_app_channel_is_internal(struct ast_channel *chan);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Mark this unreal channel and it's other half as being internal to Stasis.
|
|
|
|
*
|
|
|
|
* \param chan The channel to mark.
|
|
|
|
*
|
|
|
|
* \retval zero Success
|
|
|
|
* \retval non-zero Failure
|
|
|
|
*/
|
|
|
|
int stasis_app_channel_unreal_set_internal(struct ast_channel *chan);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Mark this channel as being internal to Stasis.
|
|
|
|
*
|
|
|
|
* \param chan The channel to mark.
|
|
|
|
*
|
|
|
|
* \retval zero Success
|
|
|
|
* \retval non-zero Failure
|
|
|
|
*/
|
|
|
|
int stasis_app_channel_set_internal(struct ast_channel *chan);
|
|
|
|
|
2016-03-30 17:18:39 -05:00
|
|
|
/*!
|
|
|
|
* \brief Dial a channel
|
|
|
|
* \param control Control for \c res_stasis.
|
2016-05-09 14:48:51 -05:00
|
|
|
* \param dialstring The dialstring to pass to the channel driver
|
|
|
|
* \param timeout Optional timeout in milliseconds
|
2016-03-30 17:18:39 -05:00
|
|
|
*/
|
2016-05-09 14:48:51 -05:00
|
|
|
int stasis_app_control_dial(struct stasis_app_control *control,
|
|
|
|
const char *dialstring, unsigned int timeout);
|
2016-03-30 17:18:39 -05:00
|
|
|
|
|
|
|
/*!
|
2016-05-09 14:48:51 -05:00
|
|
|
* \brief Let Stasis app internals shut down
|
|
|
|
*
|
|
|
|
* This is called when res_stasis is unloaded. It ensures that
|
|
|
|
* the Stasis app internals can free any resources they may have
|
|
|
|
* allocated during the time that res_stasis was loaded.
|
2016-03-30 17:18:39 -05:00
|
|
|
*/
|
2016-05-09 14:48:51 -05:00
|
|
|
void stasis_app_control_shutdown(void);
|
2017-01-19 08:05:36 -07:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Enable/disable request/response and event logging on an application
|
|
|
|
*
|
|
|
|
* \param app The app to debug
|
|
|
|
* \param debug If non-zero, enable debugging. If zero, disable.
|
|
|
|
*/
|
|
|
|
void stasis_app_set_debug(struct stasis_app *app, int debug);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Enable/disable request/response and event logging on an application
|
|
|
|
*
|
|
|
|
* \param app_name The app name to debug
|
|
|
|
* \param debug If non-zero, enable debugging. If zero, disable.
|
|
|
|
*/
|
|
|
|
void stasis_app_set_debug_by_name(const char *app_name, int debug);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Get debug status of an application
|
|
|
|
*
|
|
|
|
* \param app The app to check
|
|
|
|
* \return The debug flag for the app || the global debug flag
|
|
|
|
*/
|
|
|
|
int stasis_app_get_debug(struct stasis_app *app);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Get debug status of an application
|
|
|
|
*
|
|
|
|
* \param app_name The app_name to check
|
|
|
|
* \return The debug flag for the app || the global debug flag
|
|
|
|
*/
|
|
|
|
int stasis_app_get_debug_by_name(const char *app_name);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Enable/disable request/response and event logging on all applications
|
|
|
|
*
|
|
|
|
* \param debug If non-zero, enable debugging. If zero, disable.
|
|
|
|
*/
|
|
|
|
void stasis_app_set_global_debug(int debug);
|
|
|
|
|
|
|
|
struct ast_cli_args;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Dump properties of a \c stasis_app to the CLI
|
|
|
|
*
|
|
|
|
* \param app The application
|
|
|
|
* \param a The CLI arguments
|
|
|
|
*/
|
|
|
|
void stasis_app_to_cli(const struct stasis_app *app, struct ast_cli_args *a);
|
|
|
|
|
2019-02-08 14:48:27 -06:00
|
|
|
/*!
|
|
|
|
* \brief Convert and add the app's event type filter(s) to the given json object.
|
|
|
|
*
|
|
|
|
* \param app The application
|
|
|
|
* \param json The json object to add the filter data to
|
|
|
|
*
|
|
|
|
* \return The given json object
|
|
|
|
*/
|
|
|
|
struct ast_json *stasis_app_event_filter_to_json(struct stasis_app *app, struct ast_json *json);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Set the application's event type filter
|
|
|
|
*
|
|
|
|
* \param app The application
|
|
|
|
* \param filter The allowed and/or disallowed event filter
|
|
|
|
*
|
|
|
|
* \return 0 if successfully set
|
|
|
|
*/
|
|
|
|
int stasis_app_event_filter_set(struct stasis_app *app, struct ast_json *filter);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Check if the given event should be filtered.
|
|
|
|
*
|
|
|
|
* Attempts first to find the event in the application's disallowed events list.
|
|
|
|
* If found then the event won't be sent to the remote. If not found in the
|
|
|
|
* disallowed list then a search is done to see if it can be found in the allowed
|
|
|
|
* list. If found the event message is sent, otherwise it is not sent.
|
|
|
|
*
|
|
|
|
* \param app_name The application name
|
|
|
|
* \param event The event to check
|
|
|
|
*
|
|
|
|
* \return True if allowed, false otherwise
|
|
|
|
*/
|
|
|
|
int stasis_app_event_allowed(const char *app_name, struct ast_json *event);
|
|
|
|
|
2013-04-08 13:27:45 +00:00
|
|
|
/*! @} */
|
|
|
|
|
2013-04-15 16:43:47 +00:00
|
|
|
#endif /* _ASTERISK_STASIS_APP_H */
|