Asterisk - The Open Source Telephony Project GIT-master-590b490
Loading...
Searching...
No Matches
stasis_app_broadcast.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2026, Aurora Innovation AB
5 *
6 * Daniel Donoghue <daniel.donoghue@aurorainnovation.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#ifndef _ASTERISK_STASIS_APP_BROADCAST_H
20#define _ASTERISK_STASIS_APP_BROADCAST_H
21
22/*! \file
23 *
24 * \brief Stasis Application Broadcast API
25 *
26 * \author Daniel Donoghue <daniel.donoghue@aurorainnovation.com>
27 *
28 * This module provides the infrastructure for broadcasting incoming channels
29 * to multiple ARI applications and handling first-claim winner logic.
30 */
31
32#include "asterisk/channel.h"
34
35/*! \brief Suppress CallClaimed event for this broadcast */
36#define STASIS_BROADCAST_FLAG_SUPPRESS_CLAIMED (1 << 0)
37
38/*!
39 * \brief Start a broadcast for a channel
40 *
41 * \since 20
42 *
43 * Broadcasts a channel to all ARI applications (or filtered applications)
44 * allowing them to claim the channel. Only the first claim will succeed.
45 *
46 * When a channel is claimed, a CallClaimed event is sent only to applications
47 * that matched the \a app_filter (or all apps if no filter was set). This can
48 * be suppressed entirely with #STASIS_BROADCAST_FLAG_SUPPRESS_CLAIMED.
49 *
50 * \param chan The channel to broadcast
51 * \param timeout_ms Timeout in milliseconds to wait for a claim
52 * \param app_filter Optional regex filter for application names (NULL for all)
53 * \param flags Combination of STASIS_BROADCAST_FLAG_* values
54 *
55 * \retval 0 on success
56 * \retval -1 on error
57 * \retval AST_OPTIONAL_API_UNAVAILABLE if res_stasis_broadcast is not loaded
58 */
60 (struct ast_channel *chan, int timeout_ms, const char *app_filter,
61 unsigned int flags),
63
64/*!
65 * \brief Attempt to claim a broadcast channel
66 *
67 * \since 20
68 *
69 * Atomically attempts to claim a channel that is in broadcast state.
70 * Only the first claim for a given channel will succeed.
71 *
72 * \param channel_id The unique ID of the channel
73 * \param app_name The name of the application claiming the channel
74 *
75 * \retval 0 if claim successful
76 * \retval -1 if channel not found
77 * \retval -2 if already claimed by another application
78 * \retval AST_OPTIONAL_API_UNAVAILABLE if res_stasis_broadcast is not loaded
79 */
81 (const char *channel_id, const char *app_name),
83
84/*!
85 * \brief Get the winner app name for a broadcast channel
86 *
87 * \since 20
88 *
89 * \param channel_id The unique ID of the channel
90 *
91 * \return A copy of the winner app name (caller must free with ast_free),
92 * or NULL if not claimed or not found
93 * \retval NULL if res_stasis_broadcast is not loaded
94 */
96 (const char *channel_id),
97 { return NULL; });
98
99/*!
100 * \brief Wait for a broadcast channel to be claimed
101 *
102 * \since 20
103 *
104 * Blocks until the channel is claimed or the timeout expires.
105 *
106 * \param chan The channel
107 * \param timeout_ms Maximum time to wait in milliseconds
108 *
109 * \retval 0 if claimed within timeout
110 * \retval -1 if timeout expired or error
111 * \retval AST_OPTIONAL_API_UNAVAILABLE if res_stasis_broadcast is not loaded
112 */
114 (struct ast_channel *chan, int timeout_ms),
115 { return AST_OPTIONAL_API_UNAVAILABLE; });
116
117/*!
118 * \brief Clean up broadcast context for a channel
119 *
120 * \since 20
121 *
122 * Removes the broadcast context when the channel is done or leaving the
123 * broadcast state.
124 *
125 * \param channel_id The unique ID of the channel
126 */
128 (const char *channel_id),
129 { return; });
130
131#endif /* _ASTERISK_STASIS_APP_BROADCAST_H */
General Asterisk PBX channel definitions.
Optional API function macros.
#define AST_OPTIONAL_API_UNAVAILABLE
A common value for optional API stub functions to return.
#define AST_OPTIONAL_API(result, name, proto, stub)
Declare an optional API function.
const char * app_name(struct ast_app *app)
Definition pbx_app.c:475
#define NULL
Definition resample.c:96
void AST_OPTIONAL_API_NAME() stasis_app_broadcast_cleanup(const char *channel_id)
Clean up broadcast context for a channel.
int AST_OPTIONAL_API_NAME() stasis_app_broadcast_wait(struct ast_channel *chan, int timeout_ms)
Wait for a broadcast channel to be claimed.
int AST_OPTIONAL_API_NAME() stasis_app_broadcast_channel(struct ast_channel *chan, int timeout_ms, const char *app_filter, unsigned int flags)
Start a broadcast for a channel.
char *AST_OPTIONAL_API_NAME() stasis_app_broadcast_winner(const char *channel_id)
Get the winner app name for a broadcast channel.
int AST_OPTIONAL_API_NAME() stasis_app_claim_channel(const char *channel_id, const char *app_name)
Attempt to claim a broadcast channel.
Main Channel structure associated with a channel.