Asterisk - The Open Source Telephony Project GIT-master-7988d11
Loading...
Searching...
No Matches
Typedefs | Functions
stasis_app_impl.h File Reference

Backend API for implementing components of res_stasis. More...

#include "asterisk/stasis_app.h"
Include dependency graph for stasis_app_impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* command_data_destructor_fn) (void *data)
 Typedef for data destructor for stasis app commands.
 
typedef int(* stasis_app_command_cb) (struct stasis_app_control *control, struct ast_channel *chan, void *data)
 

Functions

int stasis_app_exec (struct ast_channel *chan, const char *app_name, int argc, char *argv[])
 Control a channel using stasis_app.
 
int stasis_app_send_command (struct stasis_app_control *control, stasis_app_command_cb command, void *data, command_data_destructor_fn data_destructor)
 Invokes a command on a control's channel.
 
int stasis_app_send_command_async (struct stasis_app_control *control, stasis_app_command_cb command, void *data, command_data_destructor_fn data_destructor)
 Asynchronous version of stasis_app_send_command().
 

Detailed Description

Backend API for implementing components of res_stasis.

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m
Since
12

This file defines functions useful for defining new commands to execute on channels while they are in Stasis.

Definition in file stasis_app_impl.h.

Typedef Documentation

◆ command_data_destructor_fn

typedef void(* command_data_destructor_fn) (void *data)

Typedef for data destructor for stasis app commands.

This is called during destruction of the command or if we fail to schedule a command. It is passed a pointer to the user-defined data of the command.

Parameters
dataData to destroy.

Definition at line 59 of file stasis_app_impl.h.

◆ stasis_app_command_cb

typedef int(* stasis_app_command_cb) (struct stasis_app_control *control, struct ast_channel *chan, void *data)

Callback type for stasis app commands

Definition at line 62 of file stasis_app_impl.h.

Function Documentation

◆ stasis_app_exec()

int stasis_app_exec ( struct ast_channel chan,
const char *  app_name,
int  argc,
char *  argv[] 
)

Control a channel using stasis_app.

Since
12

This function blocks until the channel hangs up, or stasis_app_control_continue() is called on the channel's stasis_app_control struct.

Parameters
chanChannel to control with Stasis.
app_nameApplication controlling the channel.
argcNumber of arguments for the application.
argvArguments for the application.

Control a channel using stasis_app.

Definition at line 1376 of file res_stasis.c.

1378{
1379 RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
1380 RAII_VAR(struct stasis_app_control *, control, NULL, control_unlink);
1381 struct ast_bridge *bridge = NULL;
1382 int res = 0;
1383 int needs_depart;
1384
1385 ast_assert(chan != NULL);
1386
1387 /* Just in case there's a lingering indication that the channel has had a stasis
1388 * end published on it, remove that now.
1389 */
1391
1392 if (!apps_registry) {
1393 return -1;
1394 }
1395
1397 if (!app) {
1399 "Stasis app '%s' not registered\n", app_name);
1400 return -1;
1401 }
1402 if (!app_is_active(app)) {
1404 "Stasis app '%s' not active\n", app_name);
1405 return -1;
1406 }
1407
1408 control = control_create(chan, app);
1409 if (!control) {
1410 ast_log(LOG_ERROR, "Control allocation failed or Stasis app '%s' not registered\n", app_name);
1411 return -1;
1412 }
1413
1414 if (!control_app(control)) {
1415 ast_log(LOG_ERROR, "Stasis app '%s' not registered\n", app_name);
1416 return -1;
1417 }
1418
1419 if (!app_is_active(control_app(control))) {
1420 ast_log(LOG_ERROR, "Stasis app '%s' not active\n", app_name);
1421 return -1;
1422 }
1423 ao2_link(app_controls, control);
1424
1425 if (add_masquerade_store(chan)) {
1426 ast_log(LOG_ERROR, "Failed to attach masquerade detector\n");
1427 return -1;
1428 }
1429
1430 res = send_start_msg(control_app(control), chan, argc, argv);
1431 if (res != 0) {
1433 "Error sending start message to '%s'\n", app_name);
1435 return -1;
1436 }
1437
1438 /* Pull queued prestart commands and execute */
1439 control_prestart_dispatch_all(control, chan);
1440
1441 while (!control_is_done(control)) {
1442 RAII_VAR(struct ast_frame *, f, NULL, ast_frame_dtor);
1443 int r;
1444 int command_count;
1445 RAII_VAR(struct ast_bridge *, last_bridge, NULL, ao2_cleanup);
1446
1447 /* Check to see if a bridge absorbed our hangup frame */
1448 if (ast_check_hangup_locked(chan)) {
1449 control_mark_done(control);
1450 break;
1451 }
1452
1453 /* control->next_app is only modified within the control thread, so this is safe */
1454 if (control_next_app(control)) {
1455 struct stasis_app *next_app = ao2_find(apps_registry, control_next_app(control), OBJ_SEARCH_KEY);
1456
1457 if (next_app && app_is_active(next_app)) {
1458 int idx;
1459 int next_argc;
1460 char **next_argv;
1461
1462 /* If something goes wrong in this conditional, res will need to be non-zero
1463 * so that the code below the exec loop knows something went wrong during a move.
1464 */
1466 res = has_masquerade_store(chan) && app_send_end_msg(control_app(control), chan);
1467 if (res != 0) {
1469 "Error sending end message to %s\n", stasis_app_name(control_app(control)));
1470 control_mark_done(control);
1471 ao2_ref(next_app, -1);
1472 break;
1473 }
1474 } else {
1476 }
1477
1478 /* This will ao2_bump next_app, and unref the previous app by 1 */
1479 control_set_app(control, next_app);
1480
1481 /* There's a chance that the previous application is ready for clean up, so go ahead
1482 * and do that now.
1483 */
1484 cleanup();
1485
1486 /* We need to add another masquerade store, otherwise the leave message will
1487 * not show up for the correct application.
1488 */
1489 if (add_masquerade_store(chan)) {
1490 ast_log(LOG_ERROR, "Failed to attach masquerade detector\n");
1491 res = -1;
1492 control_mark_done(control);
1493 ao2_ref(next_app, -1);
1494 break;
1495 }
1496
1497 /* We MUST get the size before the list, as control_next_app_args steals the elements
1498 * from the string vector.
1499 */
1500 next_argc = control_next_app_args_size(control);
1501 next_argv = control_next_app_args(control);
1502
1503 res = send_start_msg(control_app(control), chan, next_argc, next_argv);
1504
1505 /* Even if res != 0, we still need to free the memory we got from control_argv */
1506 if (next_argv) {
1507 for (idx = 0; idx < next_argc; idx++) {
1508 ast_free(next_argv[idx]);
1509 }
1510 ast_free(next_argv);
1511 }
1512
1513 if (res != 0) {
1515 "Error sending start message to '%s'\n", stasis_app_name(control_app(control)));
1517 control_mark_done(control);
1518 ao2_ref(next_app, -1);
1519 break;
1520 }
1521
1522 /* Done switching applications, free memory and clean up */
1523 control_move_cleanup(control);
1524 } else {
1525 /* If we can't switch applications, do nothing */
1526 struct ast_json *msg;
1527 RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
1528
1529 if (!next_app) {
1530 ast_log(LOG_ERROR, "Could not move to Stasis app '%s' - not registered\n",
1531 control_next_app(control));
1532 } else {
1533 ast_log(LOG_ERROR, "Could not move to Stasis app '%s' - not active\n",
1534 control_next_app(control));
1535 }
1536
1538 if (!snapshot) {
1539 ast_log(LOG_ERROR, "Could not get channel shapshot for '%s'\n",
1540 ast_channel_name(chan));
1541 } else {
1542 struct ast_json *json_args;
1543 int next_argc = control_next_app_args_size(control);
1544 char **next_argv = control_next_app_args(control);
1545
1546 msg = ast_json_pack("{s: s, s: o, s: o, s: s, s: []}",
1547 "type", "ApplicationMoveFailed",
1548 "timestamp", ast_json_timeval(ast_tvnow(), NULL),
1549 "channel", ast_channel_snapshot_to_json(snapshot, NULL),
1550 "destination", control_next_app(control),
1551 "args");
1552 if (!msg) {
1553 ast_log(LOG_ERROR, "Failed to pack JSON for ApplicationMoveFailed message\n");
1554 } else {
1555 json_args = ast_json_object_get(msg, "args");
1556 if (!json_args) {
1557 ast_log(LOG_ERROR, "Could not get args json array");
1558 } else {
1559 int r = 0;
1560 int idx;
1561 for (idx = 0; idx < next_argc; ++idx) {
1562 r = ast_json_array_append(json_args,
1563 ast_json_string_create(next_argv[idx]));
1564 if (r != 0) {
1565 ast_log(LOG_ERROR, "Error appending to ApplicationMoveFailed message\n");
1566 break;
1567 }
1568 }
1569 if (r == 0) {
1570 app_send(control_app(control), msg);
1571 }
1572 }
1573 ast_json_unref(msg);
1574 }
1575 }
1576 }
1577 control_move_cleanup(control);
1578 ao2_cleanup(next_app);
1579 }
1580
1581 last_bridge = bridge;
1582 bridge = ao2_bump(stasis_app_get_bridge(control));
1583
1584 if (bridge != last_bridge) {
1585 if (last_bridge) {
1586 app_unsubscribe_bridge(control_app(control), last_bridge);
1587 }
1588 if (bridge) {
1589 app_subscribe_bridge(control_app(control), bridge);
1590 }
1591 }
1592
1593 if (bridge) {
1594 /* Bridge/dial is handling channel frames */
1595 control_wait(control);
1596 control_dispatch_all(control, chan);
1597 continue;
1598 }
1599
1600 r = ast_waitfor(chan, MAX_WAIT_MS);
1601
1602 if (r < 0) {
1603 ast_debug(3, "%s: Poll error\n",
1604 ast_channel_uniqueid(chan));
1605 control_mark_done(control);
1606 break;
1607 }
1608
1609 command_count = control_dispatch_all(control, chan);
1610
1611 if (command_count > 0 && ast_channel_fdno(chan) == -1) {
1612 /* Command drained the channel; wait for next frame */
1613 continue;
1614 }
1615
1616 if (r == 0) {
1617 /* Timeout */
1618 continue;
1619 }
1620
1621 f = ast_read(chan);
1622 if (!f) {
1623 /* Continue on in the dialplan */
1624 ast_debug(3, "%s: Hangup (no more frames)\n",
1625 ast_channel_uniqueid(chan));
1626 control_mark_done(control);
1627 break;
1628 }
1629
1630 if (f->frametype == AST_FRAME_CONTROL) {
1631 if (f->subclass.integer == AST_CONTROL_HANGUP) {
1632 /* Continue on in the dialplan */
1633 ast_debug(3, "%s: Hangup\n",
1634 ast_channel_uniqueid(chan));
1635 control_mark_done(control);
1636 break;
1637 }
1638 }
1639 }
1640
1641 ast_channel_lock(chan);
1642 needs_depart = (ast_channel_internal_bridge_channel(chan) != NULL);
1643 ast_channel_unlock(chan);
1644 if (needs_depart) {
1645 ast_bridge_depart(chan);
1646 }
1647
1648 if (stasis_app_get_bridge(control)) {
1650 }
1651 ao2_cleanup(bridge);
1652
1653 /* Only publish a stasis_end event if it hasn't already been published */
1654 if (!res && !stasis_app_channel_is_stasis_end_published(chan)) {
1655 /* A masquerade has occurred and this message will be wrong so it
1656 * has already been sent elsewhere. */
1657 res = has_masquerade_store(chan) && app_send_end_msg(control_app(control), chan);
1658 if (res != 0) {
1660 "Error sending end message to %s\n", stasis_app_name(control_app(control)));
1661 return res;
1662 }
1663 } else {
1665 }
1666
1667 control_flush_queue(control);
1668
1669 /* Stop any lingering silence generator */
1670 control_silence_stop_now(control);
1671
1672 /* There's an off chance that app is ready for cleanup. Go ahead
1673 * and clean up, just in case
1674 */
1675 cleanup();
1676
1677 if (stasis_app_control_is_failed(control)) {
1678 res = -1;
1679 }
1680 /* The control needs to be removed from the controls container in
1681 * case a new PBX is started and ends up coming back into Stasis.
1682 */
1683 control_unlink(control);
1684 control = NULL;
1685
1686 if (!res && !ast_channel_pbx(chan)) {
1687 int chan_hungup;
1688
1689 /* The ASYNCGOTO softhangup flag may have broken the channel out of
1690 * its bridge to run dialplan, so if there's no pbx on the channel
1691 * let it run dialplan here. Otherwise, it will run when this
1692 * application exits. */
1693 ast_channel_lock(chan);
1695 chan_hungup = ast_check_hangup(chan);
1696 ast_channel_unlock(chan);
1697
1698 if (!chan_hungup) {
1699 struct ast_pbx_args pbx_args;
1700
1701 memset(&pbx_args, 0, sizeof(pbx_args));
1702 pbx_args.no_hangup_chan = 1;
1703
1704 res = ast_pbx_run_args(chan, &pbx_args);
1705 }
1706 }
1707
1708 return res;
1709}
static const char app[]
#define ast_free(a)
Definition astmm.h:180
#define ast_log
Definition astobj2.c:42
#define ao2_link(container, obj)
Add an object to a container.
Definition astobj2.h:1532
#define ao2_cleanup(obj)
Definition astobj2.h:1934
#define ao2_find(container, arg, flags)
Definition astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition astobj2.h:1101
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
Definition bridge.c:1975
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition channel.c:2423
int ast_channel_fdno(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition channel.h:2989
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition channel.c:3200
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
Definition channel.c:460
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4312
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
@ AST_SOFTHANGUP_ASYNCGOTO
Definition channel.h:1146
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition channel.c:446
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition channel.h:2990
struct stasis_app_control * control_create(struct ast_channel *channel, struct stasis_app *app)
Create a control object.
Definition control.c:131
int control_prestart_dispatch_all(struct stasis_app_control *control, struct ast_channel *chan)
Dispatch all queued prestart commands.
Definition control.c:1587
void control_wait(struct stasis_app_control *control)
Blocks until control's command queue has a command available.
Definition control.c:1567
char ** control_next_app_args(struct stasis_app_control *control)
Returns the list of arguments to pass to the application we are moving to.
Definition control.c:1762
int control_is_done(struct stasis_app_control *control)
Returns true if control_continue() has been called on this control.
Definition control.c:363
void control_flush_queue(struct stasis_app_control *control)
Flush the control command queue.
Definition control.c:1534
int control_dispatch_all(struct stasis_app_control *control, struct ast_channel *chan)
Dispatch all commands enqueued to this control.
Definition control.c:1547
int control_next_app_args_size(struct stasis_app_control *control)
Returns the number of arguments to be passed to the application we are moving to.
Definition control.c:1767
void control_set_app(struct stasis_app_control *control, struct stasis_app *app)
Set the application the control object belongs to.
Definition control.c:1743
void control_silence_stop_now(struct stasis_app_control *control)
Stop playing silence to a channel right now.
Definition control.c:878
char * control_next_app(struct stasis_app_control *control)
Returns the name of the application we are moving to.
Definition control.c:1749
struct stasis_app * control_app(struct stasis_app_control *control)
Returns the pointer (non-reffed) to the app associated with this control.
Definition control.c:1615
void control_move_cleanup(struct stasis_app_control *control)
Free any memory that was allocated for switching applications via /channels/{channelId}/move.
Definition control.c:1754
void control_mark_done(struct stasis_app_control *control)
Definition control.c:369
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
void ast_frame_dtor(struct ast_frame *frame)
NULL-safe wrapper for ast_frfree, good for RAII_VAR.
Definition main/frame.c:187
@ AST_FRAME_CONTROL
@ AST_CONTROL_HANGUP
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_ERROR
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition json.c:278
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
Definition json.c:378
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
Definition json.c:670
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition json.c:407
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
Definition pbx.c:4771
const char * app_name(struct ast_app *app)
Definition pbx_app.c:475
int app_subscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Add a bridge subscription to an existing channel subscription.
int app_unsubscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Cancel the bridge subscription for an application.
int app_is_active(struct stasis_app *app)
Checks whether an app is active.
void app_send(struct stasis_app *app, struct ast_json *message)
Send a message to an application.
static int send_start_msg(struct stasis_app *app, struct ast_channel *chan, int argc, char *argv[])
struct ao2_container * app_controls
Definition res_stasis.c:102
static void remove_stasis_end_published(struct ast_channel *chan)
static void cleanup(void)
Clean up any old apps that we don't need any more.
Definition res_stasis.c:327
static int add_masquerade_store(struct ast_channel *chan)
static int has_masquerade_store(struct ast_channel *chan)
int app_send_end_msg(struct stasis_app *app, struct ast_channel *chan)
Send StasisEnd message to the listening app.
#define MAX_WAIT_MS
Definition res_stasis.c:77
static void remove_masquerade_store(struct ast_channel *chan)
struct ao2_container * apps_registry
Stasis application container.
Definition res_stasis.c:100
static void control_unlink(struct stasis_app_control *control)
In addition to running ao2_cleanup(), this function also removes the object from the app_controls con...
Definition res_stasis.c:818
int stasis_app_channel_is_stasis_end_published(struct ast_channel *chan)
Has this channel had a StasisEnd published on it?
#define NULL
Definition resample.c:96
int stasis_app_control_is_failed(const struct stasis_app_control *control)
Check if a control object is marked as "failed".
Definition control.c:382
struct ast_bridge * stasis_app_get_bridge(struct stasis_app_control *control)
Gets the bridge currently associated with a control object.
Definition control.c:972
const char * stasis_app_name(const struct stasis_app *app)
Retrieve an application's name.
struct ast_json * ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_channel_snapshot.
Structure that contains information about a bridge.
Definition bridge.h:353
Structure representing a snapshot of channel state.
Data structure associated with a single frame of data.
Abstract JSON element (object, array, string, int, ...).
Options for ast_pbx_run()
Definition pbx.h:409
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition time.h:159
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981
#define ast_assert(a)
Definition utils.h:779

References add_masquerade_store(), ao2_bump, ao2_cleanup, ao2_find, ao2_link, ao2_ref, app, app_controls, app_is_active(), app_name(), app_send(), app_send_end_msg(), app_subscribe_bridge(), app_unsubscribe_bridge(), apps_registry, ast_assert, ast_bridge_depart(), ast_channel_clear_softhangup(), ast_channel_fdno(), ast_channel_internal_bridge_channel(), ast_channel_lock, ast_channel_name(), ast_channel_pbx(), ast_channel_snapshot_get_latest(), ast_channel_snapshot_to_json(), ast_channel_uniqueid(), ast_channel_unlock, ast_check_hangup(), ast_check_hangup_locked(), AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CONTROL, ast_frame_dtor(), ast_free, ast_json_array_append(), ast_json_object_get(), ast_json_pack(), ast_json_string_create(), ast_json_timeval(), ast_json_unref(), ast_log, ast_pbx_run_args(), ast_read(), AST_SOFTHANGUP_ASYNCGOTO, ast_tvnow(), ast_waitfor(), cleanup(), control_app(), control_create(), control_dispatch_all(), control_flush_queue(), control_is_done(), control_mark_done(), control_move_cleanup(), control_next_app(), control_next_app_args(), control_next_app_args_size(), control_prestart_dispatch_all(), control_set_app(), control_silence_stop_now(), control_unlink(), control_wait(), has_masquerade_store(), LOG_ERROR, MAX_WAIT_MS, ast_pbx_args::no_hangup_chan, NULL, OBJ_SEARCH_KEY, RAII_VAR, remove_masquerade_store(), remove_stasis_end_published(), send_start_msg(), stasis_app_channel_is_stasis_end_published(), stasis_app_control_is_failed(), stasis_app_get_bridge(), and stasis_app_name().

Referenced by app_exec(), and stasis_broadcast_exec().

◆ stasis_app_send_command()

int stasis_app_send_command ( struct stasis_app_control control,
stasis_app_command_cb  command,
void *  data,
command_data_destructor_fn  data_destructor 
)

Invokes a command on a control's channel.

Since
12

This function dispatches the command to be executed in the context of stasis_app_exec(), so this command will block waiting for the results of the command.

Parameters
controlControl object for the channel to send the command to.
commandCommand function to execute.
dataOptional data to pass along with the control function.
data_destructorOptional function which will be called on the data in either the event of command completion or failure to schedule or complete the command
Returns
zero on success.
error code otherwise.

Definition at line 939 of file control.c.

941{
942 return app_send_command_on_condition(control, command_fn, data, data_destructor, NULL);
943}
static int app_send_command_on_condition(struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor, app_command_can_exec_cb can_exec_fn)
Definition control.c:907

References app_send_command_on_condition(), stasis_app_command::data, stasis_app_command::data_destructor, and NULL.

Referenced by ast_ari_bridges_set_video_source(), and stasis_app_control_answer().

◆ stasis_app_send_command_async()

int stasis_app_send_command_async ( struct stasis_app_control control,
stasis_app_command_cb  command,
void *  data,
command_data_destructor_fn  data_destructor 
)

Asynchronous version of stasis_app_send_command().

Since
12

This function enqueues a command for execution, but returns immediately without waiting for the response.

Parameters
controlControl object for the channel to send the command to.
commandCommand function to execute.
dataOptional data to pass along with the control function.
data_destructorOptional function which will be called on the data in either the event of command completion or failure to schedule or complete the command
Returns
0 on success.
Non-zero on error.

Definition at line 945 of file control.c.

948{
949 struct stasis_app_command *command;
950
951 if (control == NULL || control->is_done) {
952 /* If exec_command fails, it calls the data_destructor. In order to
953 * provide consistent behavior, we'll also call the data_destructor
954 * on this error path. This way, callers never have to call the
955 * data_destructor themselves.
956 */
957 if (data_destructor) {
959 }
960 return -1;
961 }
962
963 command = exec_command(control, command_fn, data, data_destructor);
964 if (!command) {
965 return -1;
966 }
967 ao2_ref(command, -1);
968
969 return 0;
970}
static struct stasis_app_command * exec_command(struct stasis_app_control *control, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor)
Definition control.c:316
command_data_destructor_fn data_destructor
Definition command.c:38
unsigned int is_done
Definition control.c:105

References ao2_ref, stasis_app_command::data, stasis_app_command::data_destructor, exec_command(), stasis_app_control::is_done, and NULL.

Referenced by bridge_timeout(), dial_bridge_after_cb(), internal_bridge_after_cb(), stasis_app_control_add_role(), stasis_app_control_clear_roles(), stasis_app_control_continue(), stasis_app_control_dial(), stasis_app_control_dtmf(), stasis_app_control_hold(), stasis_app_control_moh_start(), stasis_app_control_moh_stop(), stasis_app_control_move(), stasis_app_control_mute(), stasis_app_control_play_uri(), stasis_app_control_progress(), stasis_app_control_record(), stasis_app_control_redirect(), stasis_app_control_ring(), stasis_app_control_ring_stop(), stasis_app_control_set_channel_var(), stasis_app_control_silence_start(), stasis_app_control_silence_stop(), stasis_app_control_unhold(), and stasis_app_control_unmute().