Asterisk - The Open Source Telephony Project GIT-master-6144b6b
Loading...
Searching...
No Matches
Data Structures | Functions
resource_bridges.h File Reference

Generated file - declares stubs to be implemented in res/ari/resource_bridges.c. More...

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

Go to the source code of this file.

Data Structures

struct  ast_ari_bridges_add_channel_args
 
struct  ast_ari_bridges_clear_video_source_args
 
struct  ast_ari_bridges_create_args
 
struct  ast_ari_bridges_create_with_id_args
 
struct  ast_ari_bridges_destroy_args
 
struct  ast_ari_bridges_get_args
 
struct  ast_ari_bridges_get_bridge_var_args
 
struct  ast_ari_bridges_get_bridge_vars_args
 
struct  ast_ari_bridges_list_args
 
struct  ast_ari_bridges_play_args
 
struct  ast_ari_bridges_play_with_id_args
 
struct  ast_ari_bridges_record_args
 
struct  ast_ari_bridges_remove_channel_args
 
struct  ast_ari_bridges_set_bridge_var_args
 
struct  ast_ari_bridges_set_bridge_vars_args
 
struct  ast_ari_bridges_set_video_source_args
 
struct  ast_ari_bridges_start_moh_args
 
struct  ast_ari_bridges_stop_moh_args
 

Functions

void ast_ari_bridges_add_channel (struct ast_variable *headers, struct ast_ari_bridges_add_channel_args *args, struct ast_ari_response *response)
 Add a channel to a bridge.
 
int ast_ari_bridges_add_channel_parse_body (struct ast_json *body, struct ast_ari_bridges_add_channel_args *args)
 Body parsing function for /bridges/{bridgeId}/addChannel.
 
void ast_ari_bridges_clear_video_source (struct ast_variable *headers, struct ast_ari_bridges_clear_video_source_args *args, struct ast_ari_response *response)
 Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk detection will be used to determine the active video stream.
 
void ast_ari_bridges_create (struct ast_variable *headers, struct ast_ari_bridges_create_args *args, struct ast_ari_response *response)
 Create a new bridge.
 
int ast_ari_bridges_create_parse_body (struct ast_json *body, struct ast_ari_bridges_create_args *args)
 Body parsing function for /bridges.
 
void ast_ari_bridges_create_with_id (struct ast_variable *headers, struct ast_ari_bridges_create_with_id_args *args, struct ast_ari_response *response)
 Create a new bridge.
 
int ast_ari_bridges_create_with_id_parse_body (struct ast_json *body, struct ast_ari_bridges_create_with_id_args *args)
 Body parsing function for /bridges/{bridgeId}.
 
void ast_ari_bridges_destroy (struct ast_variable *headers, struct ast_ari_bridges_destroy_args *args, struct ast_ari_response *response)
 Shut down a bridge.
 
void ast_ari_bridges_get (struct ast_variable *headers, struct ast_ari_bridges_get_args *args, struct ast_ari_response *response)
 Get bridge details.
 
void ast_ari_bridges_get_bridge_var (struct ast_variable *headers, struct ast_ari_bridges_get_bridge_var_args *args, struct ast_ari_response *response)
 Get the value of a bridge variable or function.
 
int ast_ari_bridges_get_bridge_var_parse_body (struct ast_json *body, struct ast_ari_bridges_get_bridge_var_args *args)
 Body parsing function for /bridges/{bridgeId}/variable.
 
void ast_ari_bridges_get_bridge_vars (struct ast_variable *headers, struct ast_ari_bridges_get_bridge_vars_args *args, struct ast_ari_response *response)
 Get the value of multiple bridge variables or functions.
 
int ast_ari_bridges_get_bridge_vars_parse_body (struct ast_json *body, struct ast_ari_bridges_get_bridge_vars_args *args)
 Body parsing function for /bridges/{bridgeId}/variables.
 
void ast_ari_bridges_list (struct ast_variable *headers, struct ast_ari_bridges_list_args *args, struct ast_ari_response *response)
 List all active bridges in Asterisk.
 
void ast_ari_bridges_play (struct ast_variable *headers, struct ast_ari_bridges_play_args *args, struct ast_ari_response *response)
 Start playback of media on a bridge.
 
int ast_ari_bridges_play_parse_body (struct ast_json *body, struct ast_ari_bridges_play_args *args)
 Body parsing function for /bridges/{bridgeId}/play.
 
void ast_ari_bridges_play_with_id (struct ast_variable *headers, struct ast_ari_bridges_play_with_id_args *args, struct ast_ari_response *response)
 Start playback of media on a bridge.
 
int ast_ari_bridges_play_with_id_parse_body (struct ast_json *body, struct ast_ari_bridges_play_with_id_args *args)
 Body parsing function for /bridges/{bridgeId}/play/{playbackId}.
 
void ast_ari_bridges_record (struct ast_variable *headers, struct ast_ari_bridges_record_args *args, struct ast_ari_response *response)
 Start a recording.
 
int ast_ari_bridges_record_parse_body (struct ast_json *body, struct ast_ari_bridges_record_args *args)
 Body parsing function for /bridges/{bridgeId}/record.
 
void ast_ari_bridges_remove_channel (struct ast_variable *headers, struct ast_ari_bridges_remove_channel_args *args, struct ast_ari_response *response)
 Remove a channel from a bridge.
 
int ast_ari_bridges_remove_channel_parse_body (struct ast_json *body, struct ast_ari_bridges_remove_channel_args *args)
 Body parsing function for /bridges/{bridgeId}/removeChannel.
 
void ast_ari_bridges_set_bridge_var (struct ast_variable *headers, struct ast_ari_bridges_set_bridge_var_args *args, struct ast_ari_response *response)
 Set the value of a bridge variable or function.
 
int ast_ari_bridges_set_bridge_var_parse_body (struct ast_json *body, struct ast_ari_bridges_set_bridge_var_args *args)
 Body parsing function for /bridges/{bridgeId}/variable.
 
void ast_ari_bridges_set_bridge_vars (struct ast_variable *headers, struct ast_ari_bridges_set_bridge_vars_args *args, struct ast_ari_response *response)
 Set the values of multiple bridge variables or functions.
 
int ast_ari_bridges_set_bridge_vars_parse_body (struct ast_json *body, struct ast_ari_bridges_set_bridge_vars_args *args)
 Body parsing function for /bridges/{bridgeId}/variables.
 
void ast_ari_bridges_set_video_source (struct ast_variable *headers, struct ast_ari_bridges_set_video_source_args *args, struct ast_ari_response *response)
 Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants.
 
void ast_ari_bridges_start_moh (struct ast_variable *headers, struct ast_ari_bridges_start_moh_args *args, struct ast_ari_response *response)
 Play music on hold to a bridge or change the MOH class that is playing.
 
int ast_ari_bridges_start_moh_parse_body (struct ast_json *body, struct ast_ari_bridges_start_moh_args *args)
 Body parsing function for /bridges/{bridgeId}/moh.
 
void ast_ari_bridges_stop_moh (struct ast_variable *headers, struct ast_ari_bridges_stop_moh_args *args, struct ast_ari_response *response)
 Stop playing music on hold to a bridge.
 

Detailed Description

Generated file - declares stubs to be implemented in res/ari/resource_bridges.c.

Bridge resources

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

Definition in file resource_bridges.h.

Function Documentation

◆ ast_ari_bridges_add_channel()

void ast_ari_bridges_add_channel ( struct ast_variable headers,
struct ast_ari_bridges_add_channel_args args,
struct ast_ari_response response 
)

Add a channel to a bridge.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 191 of file resource_bridges.c.

194{
195 RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
196 RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
197 size_t i;
198 int has_error = 0;
199
200 if (!bridge) {
201 /* Response filled in by find_bridge() */
202 return;
203 }
204
205 list = control_list_create(response, args->channel_count, args->channel);
206 if (!list) {
207 /* Response filled in by control_list_create() */
208 return;
209 }
210
211 for (i = 0; i < list->count; ++i) {
212 stasis_app_control_clear_roles(list->controls[i]);
213 if (!ast_strlen_zero(args->role)) {
214 if (stasis_app_control_add_role(list->controls[i], args->role)) {
216 return;
217 }
218 }
219
220 /* Apply bridge features to each of the channel controls */
221 if (!stasis_app_control_bridge_features_init(list->controls[i])) {
222 stasis_app_control_absorb_dtmf_in_bridge(list->controls[i], args->absorb_dtmf);
223 stasis_app_control_mute_in_bridge(list->controls[i], args->mute);
224 stasis_app_control_inhibit_colp_in_bridge(list->controls[i], args->inhibit_connected_line_updates);
225 }
226 }
227
228 for (i = 0; i < list->count; ++i) {
229 if ((has_error = check_add_remove_channel(response, list->controls[i],
231 list->controls[i], bridge)))) {
232 break;
233 }
234 }
235
236 if (!has_error) {
238 }
239}
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition res_ari.c:251
void ast_ari_response_no_content(struct ast_ari_response *response)
Fill in a No Content (204) ast_ari_response.
Definition res_ari.c:237
#define ao2_cleanup(obj)
Definition astobj2.h:1934
static struct @522 args
#define NULL
Definition resample.c:96
static struct control_list * control_list_create(struct ast_ari_response *response, size_t count, const char **channels)
static struct ast_bridge * find_bridge(struct ast_ari_response *response, const char *bridge_id)
Finds a bridge, filling the response with an error, if appropriate.
static int check_add_remove_channel(struct ast_ari_response *response, struct stasis_app_control *control, enum stasis_app_control_channel_result result)
void stasis_app_control_mute_in_bridge(struct stasis_app_control *control, int mute)
Set whether audio from the channel is muted instead of passing through to the bridge.
Definition control.c:1533
int stasis_app_control_add_channel_to_bridge(struct stasis_app_control *control, struct ast_bridge *bridge)
Add a channel to the bridge.
Definition control.c:1446
void stasis_app_control_clear_roles(struct stasis_app_control *control)
Clear bridge roles currently applied to a channel controlled by a stasis app control.
Definition control.c:353
void stasis_app_control_absorb_dtmf_in_bridge(struct stasis_app_control *control, int absorb)
Set whether DTMF from the channel is absorbed instead of passing through to the bridge.
Definition control.c:1527
int stasis_app_control_add_role(struct stasis_app_control *control, const char *role)
Apply a bridge role to a channel controlled by a stasis app control.
Definition control.c:331
void stasis_app_control_inhibit_colp_in_bridge(struct stasis_app_control *control, int inhibit_colp)
Set whether COLP frames should be generated when joining the bridge.
Definition control.c:1539
int stasis_app_control_bridge_features_init(struct stasis_app_control *control)
Initialize bridge features into a channel control.
Definition control.c:1514
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
Structure that contains information about a bridge.
Definition bridge.h:355
#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

References ao2_cleanup, args, ast_ari_response_alloc_failed(), ast_ari_response_no_content(), ast_strlen_zero(), check_add_remove_channel(), control_list_create(), find_bridge(), NULL, RAII_VAR, stasis_app_control_absorb_dtmf_in_bridge(), stasis_app_control_add_channel_to_bridge(), stasis_app_control_add_role(), stasis_app_control_bridge_features_init(), stasis_app_control_clear_roles(), stasis_app_control_inhibit_colp_in_bridge(), and stasis_app_control_mute_in_bridge().

Referenced by ast_ari_bridges_add_channel_cb().

◆ ast_ari_bridges_add_channel_parse_body()

int ast_ari_bridges_add_channel_parse_body ( struct ast_json body,
struct ast_ari_bridges_add_channel_args args 
)

Body parsing function for /bridges/{bridgeId}/addChannel.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 809 of file res_ari_bridges.c.

812{
813 struct ast_json *field;
814 /* Parse query parameters out of it */
815 field = ast_json_object_get(body, "channel");
816 if (field) {
817 /* If they were silly enough to both pass in a query param and a
818 * JSON body, free up the query value.
819 */
820 ast_free(args->channel);
821 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
822 /* Multiple param passed as array */
823 size_t i;
824 args->channel_count = ast_json_array_size(field);
825 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
826
827 if (!args->channel) {
828 return -1;
829 }
830
831 for (i = 0; i < args->channel_count; ++i) {
832 args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
833 }
834 } else {
835 /* Multiple param passed as single value */
836 args->channel_count = 1;
837 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
838 if (!args->channel) {
839 return -1;
840 }
841 args->channel[0] = ast_json_string_get(field);
842 }
843 }
844 field = ast_json_object_get(body, "role");
845 if (field) {
846 args->role = ast_json_string_get(field);
847 }
848 field = ast_json_object_get(body, "absorbDTMF");
849 if (field) {
850 args->absorb_dtmf = ast_json_is_true(field);
851 }
852 field = ast_json_object_get(body, "mute");
853 if (field) {
854 args->mute = ast_json_is_true(field);
855 }
856 field = ast_json_object_get(body, "inhibitConnectedLineUpdates");
857 if (field) {
858 args->inhibit_connected_line_updates = ast_json_is_true(field);
859 }
860 return 0;
861}
#define ast_free(a)
Definition astmm.h:180
#define ast_malloc(len)
A wrapper for malloc()
Definition astmm.h:191
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
Definition json.c:78
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
Definition json.c:370
@ AST_JSON_ARRAY
Definition json.h:165
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition json.c:283
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
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
Definition json.c:263
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Definition json.c:366
Abstract JSON element (object, array, string, int, ...).

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_is_true(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_bridges_add_channel_cb().

◆ ast_ari_bridges_clear_video_source()

void ast_ari_bridges_clear_video_source ( struct ast_variable headers,
struct ast_ari_bridges_clear_video_source_args args,
struct ast_ari_response response 
)

Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk detection will be used to determine the active video stream.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1338 of file resource_bridges.c.

1340{
1341 struct ast_bridge *bridge;
1342
1343 bridge = find_bridge(response, args->bridge_id);
1344 if (!bridge) {
1345 return;
1346 }
1347
1348 ast_bridge_lock(bridge);
1350 ast_bridge_unlock(bridge);
1351
1352 ao2_ref(bridge, -1);
1354}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
void ast_bridge_set_talker_src_video_mode(struct ast_bridge *bridge)
Set the bridge to pick the strongest talker supporting video as the single source video feed.
Definition bridge.c:3975
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition bridge.h:491
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition bridge.h:480

References ao2_ref, args, ast_ari_response_no_content(), ast_bridge_lock, ast_bridge_set_talker_src_video_mode(), ast_bridge_unlock, and find_bridge().

Referenced by ast_ari_bridges_clear_video_source_cb().

◆ ast_ari_bridges_create()

void ast_ari_bridges_create ( struct ast_variable headers,
struct ast_ari_bridges_create_args args,
struct ast_ari_response response 
)

Create a new bridge.

This bridge persists until it has been shut down, or Asterisk has been shut down.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1126 of file resource_bridges.c.

1129{
1130 RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
1131 RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup);
1132 struct ast_variable *variables = NULL;
1133 struct ast_variable *report_event_variables = NULL;
1134
1135 if (ast_bridge_topic_exists(args->bridge_id)) {
1137 response, 409, "Conflict",
1138 "Bridge with id '%s' already exists", args->bridge_id);
1139 return;
1140 }
1141
1143
1144 bridge = stasis_app_bridge_create(args->type, args->name, args->bridge_id);
1145 if (!bridge) {
1147 response, 500, "Internal Error",
1148 "Unable to create bridge. Possible duplicate bridge id '%s'", args->bridge_id);
1149 return;
1150 }
1151
1152 if (args->variables && json_to_ast_variables(response, args->variables,
1153 &variables, &report_event_variables)) {
1154 return;
1155 }
1156
1157 ast_bridge_lock(bridge);
1158 if (variables) {
1159 struct ast_variable *var;
1160
1161 for (var = variables; var; var = var->next) {
1162 int report_events = 0;
1163 struct ast_variable *report_var;
1164 char buf[strlen(var->name) + 1];
1165 char *variable;
1166 strcpy(buf, var->name);
1167 /* Strip whitespace from the variable name */
1168 variable = ast_strip(buf);
1169
1170 for (report_var = report_event_variables; report_var;
1171 report_var = report_var->next) {
1172 if (!strcmp(report_var->name, var->name)) {
1173 report_events = 1;
1174 break;
1175 }
1176 }
1177
1178 if (ast_bridge_set_variable(bridge, variable, var->value, report_events)) {
1179 ast_bridge_unlock(bridge);
1180 ast_variables_destroy(variables);
1181 ast_variables_destroy(report_event_variables);
1183 return;
1184 }
1185 }
1186 }
1187 snapshot = ast_bridge_snapshot_create(bridge);
1188 ast_bridge_unlock(bridge);
1189 ast_variables_destroy(variables);
1190 ast_variables_destroy(report_event_variables);
1191
1192 if (!snapshot) {
1194 response, 500, "Internal Error",
1195 "Unable to create snapshot for new bridge");
1196 return;
1197 }
1198
1199 ast_ari_response_ok(response,
1201}
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition res_ari.c:212
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
Definition res_ari.c:229
#define var
Definition ast_expr2f.c:605
int ast_bridge_set_variable(struct ast_bridge *bridge, const char *name, const char *value, int report_events)
Set a variable on the bridge.
Definition bridge.c:1341
char buf[BUFSIZE]
Definition eagi_proxy.c:66
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition extconf.c:1260
static int json_to_ast_variables(struct ast_ari_response *response, struct ast_json *json_variables, struct ast_variable **variables, struct ast_variable **report_event_variables)
int ast_ari_bridges_create_parse_body(struct ast_json *body, struct ast_ari_bridges_create_args *args)
Body parsing function for /bridges.
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
struct ast_bridge * stasis_app_bridge_create(const char *type, const char *name, const char *id)
Create a bridge of the specified type.
Definition res_stasis.c:898
int ast_bridge_topic_exists(const char *uniqueid)
Check if a stasis topic exists for a bridge uniqueid.
struct ast_json * ast_bridge_snapshot_to_json(const struct ast_bridge_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_bridge_snapshot.
struct ast_bridge_snapshot * ast_bridge_snapshot_create(struct ast_bridge *bridge)
Generate a snapshot of the bridge state. This is an ao2 object, so ao2_cleanup() to deallocate.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition strings.h:223
Structure that contains a snapshot of information about a bridge.
Definition bridge.h:318
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next

References ao2_cleanup, args, ast_ari_bridges_create_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_bridge_lock, ast_bridge_set_variable(), ast_bridge_snapshot_create(), ast_bridge_snapshot_to_json(), ast_bridge_topic_exists(), ast_bridge_unlock, ast_strip(), ast_variables_destroy(), buf, json_to_ast_variables(), ast_variable::name, ast_variable::next, NULL, RAII_VAR, stasis_app_bridge_create(), stasis_app_get_sanitizer(), and var.

Referenced by ast_ari_bridges_create_cb().

◆ ast_ari_bridges_create_parse_body()

int ast_ari_bridges_create_parse_body ( struct ast_json body,
struct ast_ari_bridges_create_args args 
)

Body parsing function for /bridges.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 107 of file res_ari_bridges.c.

110{
111 struct ast_json *field;
112 /* Parse query parameters out of it */
113 field = ast_json_object_get(body, "type");
114 if (field) {
115 args->type = ast_json_string_get(field);
116 }
117 field = ast_json_object_get(body, "bridgeId");
118 if (field) {
119 args->bridge_id = ast_json_string_get(field);
120 }
121 field = ast_json_object_get(body, "name");
122 if (field) {
123 args->name = ast_json_string_get(field);
124 }
125 return 0;
126}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_bridges_create().

◆ ast_ari_bridges_create_with_id()

void ast_ari_bridges_create_with_id ( struct ast_variable headers,
struct ast_ari_bridges_create_with_id_args args,
struct ast_ari_response response 
)

Create a new bridge.

This bridge persists until it has been shut down, or Asterisk has been shut down.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1203 of file resource_bridges.c.

1206{
1207 RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
1208 RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup);
1209 struct ast_variable *variables = NULL;
1210 struct ast_variable *report_event_variables = NULL;
1211
1212 if (ast_bridge_topic_exists(args->bridge_id)) {
1214 response, 409, "Conflict",
1215 "Bridge with id '%s' already exists", args->bridge_id);
1216 return;
1217 }
1218
1220
1221 bridge = stasis_app_bridge_create(args->type, args->name, args->bridge_id);
1222 if (!bridge) {
1224 response, 500, "Internal Error",
1225 "Unable to create bridge");
1226 return;
1227 }
1228
1229 if (args->variables) {
1230 struct ast_json *json_variables;
1231
1232 json_variables = ast_json_object_get(args->variables, "variables");
1233 if (json_variables && json_to_ast_variables(response, json_variables,
1234 &variables, &report_event_variables)) {
1235 if (args->variables) {
1236 ast_log(LOG_WARNING, "Failed to parse variables for new bridge '%s'\n", args->bridge_id);
1237 } else {
1238 ast_log(LOG_WARNING, "Failed to find variables for new bridge '%s'\n", args->bridge_id);
1239 }
1240 return;
1241 }
1242 }
1243
1244 ast_bridge_lock(bridge);
1245 if (variables) {
1246 struct ast_variable *var;
1247
1248 for (var = variables; var; var = var->next) {
1249 int report_events = 0;
1250 struct ast_variable *report_var;
1251 char buf[strlen(var->name) + 1];
1252 char *variable;
1253 strcpy(buf, var->name);
1254 /* Strip whitespace from the variable name */
1255 variable = ast_strip(buf);
1256
1257 report_events = 0;
1258 for (report_var = report_event_variables; report_var;
1259 report_var = report_var->next) {
1260 if (!strcmp(report_var->name, var->name)) {
1261 report_events = 1;
1262 break;
1263 }
1264 }
1265
1266 if (ast_bridge_set_variable(bridge, variable, var->value, report_events)) {
1267 ast_bridge_unlock(bridge);
1268 ast_variables_destroy(variables);
1269 ast_variables_destroy(report_event_variables);
1271 return;
1272 }
1273 }
1274 }
1275 snapshot = ast_bridge_snapshot_create(bridge);
1276 ast_bridge_unlock(bridge);
1277 ast_variables_destroy(variables);
1278 ast_variables_destroy(report_event_variables);
1279
1280 if (!snapshot) {
1282 response, 500, "Internal Error",
1283 "Unable to create snapshot for new bridge");
1284 return;
1285 }
1286
1287 ast_ari_response_ok(response,
1289}
#define ast_log
Definition astobj2.c:42
#define LOG_WARNING
int ast_ari_bridges_create_with_id_parse_body(struct ast_json *body, struct ast_ari_bridges_create_with_id_args *args)
Body parsing function for /bridges/{bridgeId}.

References ao2_cleanup, args, ast_ari_bridges_create_with_id_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_bridge_lock, ast_bridge_set_variable(), ast_bridge_snapshot_create(), ast_bridge_snapshot_to_json(), ast_bridge_topic_exists(), ast_bridge_unlock, ast_json_object_get(), ast_log, ast_strip(), ast_variables_destroy(), buf, json_to_ast_variables(), LOG_WARNING, ast_variable::name, ast_variable::next, NULL, RAII_VAR, stasis_app_bridge_create(), stasis_app_get_sanitizer(), and var.

Referenced by ast_ari_bridges_create_with_id_cb().

◆ ast_ari_bridges_create_with_id_parse_body()

int ast_ari_bridges_create_with_id_parse_body ( struct ast_json body,
struct ast_ari_bridges_create_with_id_args args 
)

Body parsing function for /bridges/{bridgeId}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 195 of file res_ari_bridges.c.

198{
199 struct ast_json *field;
200 /* Parse query parameters out of it */
201 field = ast_json_object_get(body, "type");
202 if (field) {
203 args->type = ast_json_string_get(field);
204 }
205 field = ast_json_object_get(body, "name");
206 if (field) {
207 args->name = ast_json_string_get(field);
208 }
209 return 0;
210}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_bridges_create_with_id().

◆ ast_ari_bridges_destroy()

void ast_ari_bridges_destroy ( struct ast_variable headers,
struct ast_ari_bridges_destroy_args args,
struct ast_ari_response response 
)

Shut down a bridge.

If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 962 of file resource_bridges.c.

965{
966 RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
967 if (!bridge) {
968 return;
969 }
970
973}
void stasis_app_bridge_destroy(const char *bridge_id)
Destroy the bridge.
Definition res_stasis.c:908

References ao2_cleanup, args, ast_ari_response_no_content(), ast_channel::bridge, find_bridge(), RAII_VAR, and stasis_app_bridge_destroy().

Referenced by ast_ari_bridges_destroy_cb().

◆ ast_ari_bridges_get()

void ast_ari_bridges_get ( struct ast_variable headers,
struct ast_ari_bridges_get_args args,
struct ast_ari_response response 
)

Get bridge details.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 946 of file resource_bridges.c.

949{
951 if (!snapshot) {
953 response, 404, "Not Found",
954 "Bridge not found");
955 return;
956 }
957
958 ast_ari_response_ok(response,
960}
struct ast_bridge_snapshot * ast_bridge_get_snapshot_by_uniqueid(const char *bridge_id)
Returns the current snapshot for the bridge.

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_ok(), ast_bridge_get_snapshot_by_uniqueid(), ast_bridge_snapshot_to_json(), RAII_VAR, ast_channel::snapshot, and stasis_app_get_sanitizer().

Referenced by ast_ari_bridges_get_cb().

◆ ast_ari_bridges_get_bridge_var()

void ast_ari_bridges_get_bridge_var ( struct ast_variable headers,
struct ast_ari_bridges_get_bridge_var_args args,
struct ast_ari_response response 
)

Get the value of a bridge variable or function.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1356 of file resource_bridges.c.

1359{
1360 RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
1361 struct ast_bridge *bridge;
1362 const char *value;
1363
1364 if (ast_strlen_zero(args->variable)) {
1365 ast_ari_response_error(response, 400, "Bad Request",
1366 "Variable name is required");
1367 return;
1368 }
1369
1370 bridge = find_bridge(response, args->bridge_id);
1371 if (!bridge) {
1372 return;
1373 }
1374
1375 ast_bridge_lock(bridge);
1376 value = ast_bridge_get_variable(bridge, args->variable);
1377 ast_bridge_unlock(bridge);
1378
1379 if (!value) {
1380 ao2_ref(bridge, -1);
1381 ast_ari_response_error(response, 404, "Not Found",
1382 "Provided variable was not found");
1383 return;
1384 }
1385
1386 json = ast_json_pack("{s: s}", "value", value);
1387 ao2_ref(bridge, -1);
1388
1389 if (!json) {
1391 return;
1392 }
1393
1394 ast_ari_response_ok(response, ast_json_ref(json));
1395}
const char * ast_bridge_get_variable(const struct ast_bridge *bridge, const char *name)
Get value a variable from the bridge by name.
Definition bridge.c:1380
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition json.c:67
int value
Definition syslog.c:37

References ao2_ref, args, ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_bridge_get_variable(), ast_bridge_lock, ast_bridge_unlock, ast_json_pack(), ast_json_ref(), ast_json_unref(), ast_strlen_zero(), find_bridge(), NULL, RAII_VAR, and value.

Referenced by ast_ari_bridges_get_bridge_var_cb().

◆ ast_ari_bridges_get_bridge_var_parse_body()

int ast_ari_bridges_get_bridge_var_parse_body ( struct ast_json body,
struct ast_ari_bridges_get_bridge_var_args args 
)

Body parsing function for /bridges/{bridgeId}/variable.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 402 of file res_ari_bridges.c.

405{
406 struct ast_json *field;
407 /* Parse query parameters out of it */
408 field = ast_json_object_get(body, "variable");
409 if (field) {
410 args->variable = ast_json_string_get(field);
411 }
412 return 0;
413}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_bridges_get_bridge_var_cb().

◆ ast_ari_bridges_get_bridge_vars()

void ast_ari_bridges_get_bridge_vars ( struct ast_variable headers,
struct ast_ari_bridges_get_bridge_vars_args args,
struct ast_ari_response response 
)

Get the value of multiple bridge variables or functions.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1431 of file resource_bridges.c.

1434{
1435 int res;
1437 RAII_VAR(struct ast_json *, inner_json, ast_json_object_create(), ast_json_unref);
1438 RAII_VAR(struct ast_str *, value, ast_str_create(32), ast_free);
1439 RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
1440
1441 ast_assert(response != NULL);
1442
1443 if (!json || !inner_json || !value) {
1445 return;
1446 }
1447
1448 if (args->variables_count == 0) {
1450 response, 400, "Bad Request",
1451 "At least one variable name is required");
1452 return;
1453 }
1454
1455 if (ast_strlen_zero(args->bridge_id)) {
1457 response, 400, "Bad Request",
1458 "Bridge ID is required");
1459 return;
1460 }
1461
1462 bridge = stasis_app_bridge_find_by_id(args->bridge_id);
1463 if (!bridge) {
1465 response, 404, "Bridge Not Found",
1466 "Provided bridge was not found");
1467 return;
1468 }
1469
1470 for (int i = 0; i < args->variables_count; i++) {
1471 struct ast_json *json_str;
1472 char buf[strlen(args->variables[i]) + 1];
1473 char *variable;
1474 const char *var_value;
1475
1476 strcpy(buf, args->variables[i]);
1477 variable = ast_strip(buf);
1478 if (ast_strlen_zero(variable)) {
1480 response, 400, "Bad Request",
1481 "Variable names are required");
1482 return;
1483 }
1484
1485 if (variable[strlen(variable) - 1] == ')') {
1486 if (ast_func_read2(NULL, variable, &value, 0)) {
1488 response, 500, "Error With Function",
1489 "Unable to read provided function");
1490 return;
1491 }
1492 } else {
1493 ast_bridge_lock(bridge);
1494 var_value = ast_bridge_get_variable(bridge, variable);
1495 ast_bridge_unlock(bridge);
1496 if (!var_value) {
1498 response, 404, "Variable Not Found",
1499 "Provided variable was not found");
1500 return;
1501 }
1502 ast_str_set(&value, 0, "%s", var_value);
1503 }
1504
1506 if (!json_str) {
1508 return;
1509 }
1510
1511 res = ast_json_object_set(inner_json, variable, json_str);
1512 if (res) {
1514 ast_json_unref(json_str);
1515 return;
1516 }
1517 }
1518
1519 res = ast_json_object_set(json, "variables", ast_json_ref(inner_json));
1520 if (res) {
1522 return;
1523 }
1524
1525 ast_ari_response_ok(response, ast_json_ref(json));
1526}
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition json.c:278
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
Definition json.c:399
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition json.c:414
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
struct ast_bridge * stasis_app_bridge_find_by_id(const char *bridge_id)
Returns the bridge with the given id.
Definition res_stasis.c:807
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition strings.h:1113
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
Support for dynamic strings.
Definition strings.h:623
#define ast_assert(a)
Definition utils.h:779

References ao2_cleanup, args, ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_assert, ast_bridge_get_variable(), ast_bridge_lock, ast_bridge_unlock, ast_free, ast_func_read2(), ast_json_object_create(), ast_json_object_set(), ast_json_ref(), ast_json_string_create(), ast_json_unref(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_strip(), ast_strlen_zero(), buf, NULL, RAII_VAR, stasis_app_bridge_find_by_id(), and value.

Referenced by ast_ari_bridges_get_bridge_vars_cb().

◆ ast_ari_bridges_get_bridge_vars_parse_body()

int ast_ari_bridges_get_bridge_vars_parse_body ( struct ast_json body,
struct ast_ari_bridges_get_bridge_vars_args args 
)

Body parsing function for /bridges/{bridgeId}/variables.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 586 of file res_ari_bridges.c.

589{
590 struct ast_json *field;
591 /* Parse query parameters out of it */
592 field = ast_json_object_get(body, "variables");
593 if (field) {
594 /* If they were silly enough to both pass in a query param and a
595 * JSON body, free up the query value.
596 */
597 ast_free(args->variables);
598 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
599 /* Multiple param passed as array */
600 size_t i;
601 args->variables_count = ast_json_array_size(field);
602 args->variables = ast_malloc(sizeof(*args->variables) * args->variables_count);
603
604 if (!args->variables) {
605 return -1;
606 }
607
608 for (i = 0; i < args->variables_count; ++i) {
609 args->variables[i] = ast_json_string_get(ast_json_array_get(field, i));
610 }
611 } else {
612 /* Multiple param passed as single value */
613 args->variables_count = 1;
614 args->variables = ast_malloc(sizeof(*args->variables) * args->variables_count);
615 if (!args->variables) {
616 return -1;
617 }
618 args->variables[0] = ast_json_string_get(field);
619 }
620 }
621 return 0;
622}

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_bridges_get_bridge_vars_cb().

◆ ast_ari_bridges_list()

void ast_ari_bridges_list ( struct ast_variable headers,
struct ast_ari_bridges_list_args args,
struct ast_ari_response response 
)

List all active bridges in Asterisk.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 975 of file resource_bridges.c.

978{
980 RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
981 struct ao2_iterator i;
982 struct ast_bridge *bridge;
983
985 if (!bridges) {
987 return;
988 }
989
990 json = ast_json_array_create();
991 if (!json) {
993 return;
994 }
995
997 while ((bridge = ao2_iterator_next(&i))) {
998 struct ast_bridge_snapshot *snapshot;
999 struct ast_json *json_bridge = NULL;
1000
1001 /* Invisible bridges don't get shown externally and have no snapshot */
1003 ao2_ref(bridge, -1);
1004 continue;
1005 }
1006
1007 snapshot = ast_bridge_get_snapshot(bridge);
1008 if (snapshot) {
1009 json_bridge = ast_bridge_snapshot_to_json(snapshot, stasis_app_get_sanitizer());
1010 ao2_ref(snapshot, -1);
1011 }
1012
1013 ao2_ref(bridge, -1);
1014
1015 if (!json_bridge || ast_json_array_append(json, json_bridge)) {
1018 return;
1019 }
1020 }
1022
1023 ast_ari_response_ok(response, ast_json_ref(json));
1024}
#define ao2_iterator_next(iter)
Definition astobj2.h:1911
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static struct ao2_container * bridges
Definition bridge.c:132
struct ao2_container * ast_bridges(void)
Returns the global bridges container.
Definition bridge.c:196
@ AST_BRIDGE_FLAG_INVISIBLE
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_array_create(void)
Create a empty JSON array.
Definition json.c:362
struct ast_bridge_snapshot * ast_bridge_get_snapshot(struct ast_bridge *bridge)
Returns the current snapshot for the bridge.
Generic container type.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition astobj2.h:1821
struct ast_flags feature_flags
Definition bridge.h:375
#define ast_test_flag(p, flag)
Definition utils.h:64

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_ari_response_alloc_failed(), ast_ari_response_ok(), AST_BRIDGE_FLAG_INVISIBLE, ast_bridge_get_snapshot(), ast_bridge_snapshot_to_json(), ast_bridges(), ast_json_array_append(), ast_json_array_create(), ast_json_ref(), ast_json_unref(), ast_test_flag, bridges, ast_bridge::feature_flags, NULL, RAII_VAR, and stasis_app_get_sanitizer().

Referenced by ast_ari_bridges_list_cb().

◆ ast_ari_bridges_play()

void ast_ari_bridges_play ( struct ast_variable headers,
struct ast_ari_bridges_play_args args,
struct ast_ari_response response 
)

Start playback of media on a bridge.

The media URI may be any of a number of URI's. Currently sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.)

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 677 of file resource_bridges.c.

680{
681 ari_bridges_handle_play(args->bridge_id,
682 args->media,
683 args->media_count,
684 args->announcer_format,
685 args->lang,
686 args->offsetms,
687 args->skipms,
688 args->playback_id,
689 response);
690}
static void ari_bridges_handle_play(const char *args_bridge_id, const char **args_media, size_t args_media_count, const char *args_format, const char *args_lang, int args_offset_ms, int args_skipms, const char *args_playback_id, struct ast_ari_response *response)

References args, and ari_bridges_handle_play().

Referenced by ast_ari_bridges_play_cb().

◆ ast_ari_bridges_play_parse_body()

int ast_ari_bridges_play_parse_body ( struct ast_json body,
struct ast_ari_bridges_play_args args 
)

Body parsing function for /bridges/{bridgeId}/play.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1413 of file res_ari_bridges.c.

1416{
1417 struct ast_json *field;
1418 /* Parse query parameters out of it */
1419 field = ast_json_object_get(body, "media");
1420 if (field) {
1421 /* If they were silly enough to both pass in a query param and a
1422 * JSON body, free up the query value.
1423 */
1424 ast_free(args->media);
1425 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1426 /* Multiple param passed as array */
1427 size_t i;
1428 args->media_count = ast_json_array_size(field);
1429 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1430
1431 if (!args->media) {
1432 return -1;
1433 }
1434
1435 for (i = 0; i < args->media_count; ++i) {
1436 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1437 }
1438 } else {
1439 /* Multiple param passed as single value */
1440 args->media_count = 1;
1441 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1442 if (!args->media) {
1443 return -1;
1444 }
1445 args->media[0] = ast_json_string_get(field);
1446 }
1447 }
1448 field = ast_json_object_get(body, "announcer_format");
1449 if (field) {
1450 args->announcer_format = ast_json_string_get(field);
1451 }
1452 field = ast_json_object_get(body, "lang");
1453 if (field) {
1454 args->lang = ast_json_string_get(field);
1455 }
1456 field = ast_json_object_get(body, "offsetms");
1457 if (field) {
1458 args->offsetms = ast_json_integer_get(field);
1459 }
1460 field = ast_json_object_get(body, "skipms");
1461 if (field) {
1462 args->skipms = ast_json_integer_get(field);
1463 }
1464 field = ast_json_object_get(body, "playbackId");
1465 if (field) {
1466 args->playback_id = ast_json_string_get(field);
1467 }
1468 return 0;
1469}
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition json.c:332

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_bridges_play_cb().

◆ ast_ari_bridges_play_with_id()

void ast_ari_bridges_play_with_id ( struct ast_variable headers,
struct ast_ari_bridges_play_with_id_args args,
struct ast_ari_response response 
)

Start playback of media on a bridge.

The media URI may be any of a number of URI's. Currently sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.)

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 692 of file resource_bridges.c.

695{
696 ari_bridges_handle_play(args->bridge_id,
697 args->media,
698 args->media_count,
699 args->announcer_format,
700 args->lang,
701 args->offsetms,
702 args->skipms,
703 args->playback_id,
704 response);
705}

References args, and ari_bridges_handle_play().

Referenced by ast_ari_bridges_play_with_id_cb().

◆ ast_ari_bridges_play_with_id_parse_body()

int ast_ari_bridges_play_with_id_parse_body ( struct ast_json body,
struct ast_ari_bridges_play_with_id_args args 
)

Body parsing function for /bridges/{bridgeId}/play/{playbackId}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1600 of file res_ari_bridges.c.

1603{
1604 struct ast_json *field;
1605 /* Parse query parameters out of it */
1606 field = ast_json_object_get(body, "media");
1607 if (field) {
1608 /* If they were silly enough to both pass in a query param and a
1609 * JSON body, free up the query value.
1610 */
1611 ast_free(args->media);
1612 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1613 /* Multiple param passed as array */
1614 size_t i;
1615 args->media_count = ast_json_array_size(field);
1616 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1617
1618 if (!args->media) {
1619 return -1;
1620 }
1621
1622 for (i = 0; i < args->media_count; ++i) {
1623 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1624 }
1625 } else {
1626 /* Multiple param passed as single value */
1627 args->media_count = 1;
1628 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1629 if (!args->media) {
1630 return -1;
1631 }
1632 args->media[0] = ast_json_string_get(field);
1633 }
1634 }
1635 field = ast_json_object_get(body, "announcer_format");
1636 if (field) {
1637 args->announcer_format = ast_json_string_get(field);
1638 }
1639 field = ast_json_object_get(body, "lang");
1640 if (field) {
1641 args->lang = ast_json_string_get(field);
1642 }
1643 field = ast_json_object_get(body, "offsetms");
1644 if (field) {
1645 args->offsetms = ast_json_integer_get(field);
1646 }
1647 field = ast_json_object_get(body, "skipms");
1648 if (field) {
1649 args->skipms = ast_json_integer_get(field);
1650 }
1651 return 0;
1652}

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_bridges_play_with_id_cb().

◆ ast_ari_bridges_record()

void ast_ari_bridges_record ( struct ast_variable headers,
struct ast_ari_bridges_record_args args,
struct ast_ari_response response 
)

Start a recording.

This records the mixed audio from all channels participating in this bridge.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 707 of file resource_bridges.c.

710{
711 RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
712 RAII_VAR(struct ast_channel *, record_channel, NULL, ast_hangup);
713 RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
714 RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
715 RAII_VAR(char *, recording_url, NULL, ast_free);
716 RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
718 RAII_VAR(char *, uri_encoded_name, NULL, ast_free);
719 RAII_VAR(struct stasis_forward *, channel_forward, NULL, stasis_forward_cancel);
720
721 struct stasis_topic *channel_topic;
722 struct stasis_topic *bridge_topic;
723 size_t uri_name_maxlen;
724 struct bridge_channel_control_thread_data *thread_data;
725 pthread_t threadid;
726 struct ast_format *file_format = NULL;
727 struct ast_format *channel_format = NULL;
728
729 ast_assert(response != NULL);
730
731 if (bridge == NULL) {
732 return;
733 }
734
736 if (!file_format) {
738 response, 422, "Unprocessable Entity",
739 "specified format is unknown on this system");
740 return;
741 }
742
743 if (!ast_strlen_zero(args->recorder_format)) {
744 channel_format = ast_format_cache_get(args->recorder_format);
745 if (!channel_format) {
747 response, 422, "Unprocessable Entity",
748 "specified recorder_format is unknown on this system");
749 return;
750 }
751 } else {
752 channel_format = ao2_bump(file_format);
753 }
754
755 if (!(record_channel = prepare_bridge_media_channel("Recorder", channel_format))) {
757 response, 500, "Internal Server Error", "Failed to create recording channel");
758 return;
759 }
760
761 ao2_cleanup(channel_format);
762
763 bridge_topic = ast_bridge_topic(bridge);
764 channel_topic = ast_channel_topic(record_channel);
765
766 /* Forward messages from the recording channel topic to the bridge topic so that anything listening for
767 * messages on the bridge topic will receive the recording start/stop messages. Other messages that would
768 * go to this channel will be suppressed since the channel is marked as internal.
769 */
770 if (!bridge_topic || !channel_topic || !(channel_forward = stasis_forward_all(channel_topic, bridge_topic))) {
772 response, 500, "Internal Error", "Could not forward record channel stasis messages to bridge topic");
773 return;
774 }
775
776 if (ast_unreal_channel_push_to_bridge(record_channel, bridge,
779 response, 500, "Internal Error", "Failed to put recording channel into the bridge");
780 return;
781 }
782
783 control = stasis_app_control_create(record_channel);
784 if (control == NULL) {
786 return;
787 }
788
790 if (options == NULL) {
792 return;
793 }
794
795 ast_string_field_build(options, target, "bridge:%s", args->bridge_id);
796 options->max_silence_seconds = args->max_silence_seconds;
797 options->max_duration_seconds = args->max_duration_seconds;
798 options->terminate_on =
800 options->if_exists =
802 options->beep = args->beep;
803
804 if (options->terminate_on == STASIS_APP_RECORDING_TERMINATE_INVALID) {
806 response, 400, "Bad Request",
807 "terminateOn invalid");
808 return;
809 }
810
811 if (options->if_exists == AST_RECORD_IF_EXISTS_ERROR) {
813 response, 400, "Bad Request",
814 "ifExists invalid");
815 return;
816 }
817
818 recording = stasis_app_control_record(control, options);
819 if (recording == NULL) {
820 switch(errno) {
821 case EINVAL:
822 /* While the arguments are invalid, we should have
823 * caught them prior to calling record.
824 */
826 response, 500, "Internal Server Error",
827 "Error parsing request");
828 break;
829 case EEXIST:
830 ast_ari_response_error(response, 409, "Conflict",
831 "Recording '%s' already exists and can not be overwritten",
832 args->name);
833 break;
834 case ENOMEM:
836 break;
837 case EPERM:
839 response, 400, "Bad Request",
840 "Recording name invalid");
841 break;
842 default:
844 "Unrecognized recording error: %s\n",
845 strerror(errno));
847 response, 500, "Internal Server Error",
848 "Internal Server Error");
849 break;
850 }
851 return;
852 }
853
854 uri_name_maxlen = strlen(args->name) * 3;
855 uri_encoded_name = ast_malloc(uri_name_maxlen);
856 if (!uri_encoded_name) {
858 return;
859 }
860 ast_uri_encode(args->name, uri_encoded_name, uri_name_maxlen, ast_uri_http);
861
862 if (ast_asprintf(&recording_url, "/recordings/live/%s",
863 uri_encoded_name) == -1) {
864 recording_url = NULL;
866 return;
867 }
868
869 json = stasis_app_recording_to_json(recording);
870 if (!json) {
872 return;
873 }
874
875 thread_data = ast_calloc(1, sizeof(*thread_data));
876 if (!thread_data) {
878 return;
879 }
880
881 thread_data->bridge_channel = record_channel;
882 thread_data->control = control;
883 thread_data->forward = channel_forward;
884
885 if (ast_pthread_create_detached(&threadid, NULL, bridge_channel_control_thread, thread_data)) {
887 ast_free(thread_data);
888 return;
889 }
890
891 /* These are owned by the other thread now, so we don't want RAII_VAR disposing of them. */
892 record_channel = NULL;
893 control = NULL;
894 channel_forward = NULL;
895
896 ast_ari_response_created(response, recording_url, ast_json_ref(json));
897}
void ast_ari_response_created(struct ast_ari_response *response, const char *url, struct ast_json *message)
Fill in a Created (201) ast_ari_response.
Definition res_ari.c:258
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition astmm.h:267
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
@ AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE
@ AST_BRIDGE_CHANNEL_FLAG_LONELY
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition channel.c:2540
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge *bridge, unsigned int flags)
Push the semi2 unreal channel into a bridge from either member of the unreal pair.
struct ast_format * ast_get_format_for_file_ext(const char *file_ext)
Get the ast_format associated with the given file extension.
Definition file.c:2040
#define ast_format_cache_get(name)
Retrieve a named format from the cache.
file_format
Definition func_env.c:440
@ AST_RECORD_IF_EXISTS_ERROR
int errno
static void * bridge_channel_control_thread(void *data)
static struct ast_channel * prepare_bridge_media_channel(const char *type, struct ast_format *channel_format)
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
Definition stasis.c:1626
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
Definition stasis.c:1656
struct stasis_app_control * stasis_app_control_create(struct ast_channel *chan)
Creates a control handler for a channel that isn't in a stasis app.
Definition res_stasis.c:333
struct stasis_app_recording_options * stasis_app_recording_options_create(const char *name, const char *format)
Allocate a recording options object.
struct ast_json * stasis_app_recording_to_json(const struct stasis_app_recording *recording)
Construct a JSON model of a recording.
struct stasis_app_recording * stasis_app_control_record(struct stasis_app_control *control, struct stasis_app_recording_options *options)
Record media from a channel.
enum ast_record_if_exists stasis_app_recording_if_exists_parse(const char *str)
Parse a string into the if_exists enum.
#define STASIS_APP_RECORDING_TERMINATE_INVALID
char stasis_app_recording_termination_parse(const char *str)
Parse a string into the recording termination enum.
struct stasis_topic * ast_bridge_topic(struct ast_bridge *bridge)
A topic which publishes the events for a particular bridge.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Main Channel structure associated with a channel.
Definition of a media format.
Definition format.c:43
struct stasis_app_control * control
Forwarding information.
Definition stasis.c:1609
static struct test_options options
char * ast_uri_encode(const char *string, char *outbuf, int buflen, struct ast_flags spec)
Turn text string to URI-encoded XX version.
Definition utils.c:721
const struct ast_flags ast_uri_http
Definition utils.c:717
#define ast_pthread_create_detached(a, b, c, d)
Definition utils.h:628

References ao2_bump, ao2_cleanup, args, ast_ari_response_alloc_failed(), ast_ari_response_created(), ast_ari_response_error(), ast_asprintf, ast_assert, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE, AST_BRIDGE_CHANNEL_FLAG_LONELY, ast_bridge_topic(), ast_calloc, ast_channel_topic(), ast_format_cache_get, ast_free, ast_get_format_for_file_ext(), ast_hangup(), ast_json_ref(), ast_json_unref(), ast_log, ast_malloc, ast_pthread_create_detached, AST_RECORD_IF_EXISTS_ERROR, ast_string_field_build, ast_strlen_zero(), ast_unreal_channel_push_to_bridge(), ast_uri_encode(), ast_uri_http, ast_channel::bridge, bridge_channel_control_thread_data::bridge_channel, bridge_channel_control_thread(), ast_channel::channel_forward, bridge_channel_control_thread_data::control, errno, find_bridge(), bridge_channel_control_thread_data::forward, LOG_WARNING, NULL, options, prepare_bridge_media_channel(), RAII_VAR, stasis_app_control_create(), stasis_app_control_record(), stasis_app_recording_if_exists_parse(), stasis_app_recording_options_create(), STASIS_APP_RECORDING_TERMINATE_INVALID, stasis_app_recording_termination_parse(), stasis_app_recording_to_json(), stasis_forward_all(), and stasis_forward_cancel().

Referenced by ast_ari_bridges_record_cb().

◆ ast_ari_bridges_record_parse_body()

int ast_ari_bridges_record_parse_body ( struct ast_json body,
struct ast_ari_bridges_record_args args 
)

Body parsing function for /bridges/{bridgeId}/record.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1783 of file res_ari_bridges.c.

1786{
1787 struct ast_json *field;
1788 /* Parse query parameters out of it */
1789 field = ast_json_object_get(body, "name");
1790 if (field) {
1791 args->name = ast_json_string_get(field);
1792 }
1793 field = ast_json_object_get(body, "format");
1794 if (field) {
1795 args->format = ast_json_string_get(field);
1796 }
1797 field = ast_json_object_get(body, "recorder_format");
1798 if (field) {
1799 args->recorder_format = ast_json_string_get(field);
1800 }
1801 field = ast_json_object_get(body, "maxDurationSeconds");
1802 if (field) {
1803 args->max_duration_seconds = ast_json_integer_get(field);
1804 }
1805 field = ast_json_object_get(body, "maxSilenceSeconds");
1806 if (field) {
1807 args->max_silence_seconds = ast_json_integer_get(field);
1808 }
1809 field = ast_json_object_get(body, "ifExists");
1810 if (field) {
1811 args->if_exists = ast_json_string_get(field);
1812 }
1813 field = ast_json_object_get(body, "beep");
1814 if (field) {
1815 args->beep = ast_json_is_true(field);
1816 }
1817 field = ast_json_object_get(body, "terminateOn");
1818 if (field) {
1819 args->terminate_on = ast_json_string_get(field);
1820 }
1821 return 0;
1822}

References args, ast_json_integer_get(), ast_json_is_true(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_bridges_record_cb().

◆ ast_ari_bridges_remove_channel()

void ast_ari_bridges_remove_channel ( struct ast_variable headers,
struct ast_ari_bridges_remove_channel_args args,
struct ast_ari_response response 
)

Remove a channel from a bridge.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 241 of file resource_bridges.c.

244{
245 RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
246 RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
247 size_t i;
248
249 if (!bridge) {
250 /* Response filled in by find_bridge() */
251 return;
252 }
253
254 list = control_list_create(response, args->channel_count, args->channel);
255 if (!list) {
256 /* Response filled in by control_list_create() */
257 return;
258 }
259
260 /* Make sure all of the channels are in this bridge */
261 for (i = 0; i < list->count; ++i) {
262 if (stasis_app_get_bridge(list->controls[i]) != bridge) {
263 ast_log(LOG_WARNING, "Channel %s not in bridge %s\n",
264 args->channel[i], args->bridge_id);
265 ast_ari_response_error(response, 422,
266 "Unprocessable Entity",
267 "Channel not in this bridge");
268 return;
269 }
270 }
271
272 /* Now actually remove it */
273 for (i = 0; i < list->count; ++i) {
275 bridge);
276 }
277
279}
int stasis_app_control_remove_channel_from_bridge(struct stasis_app_control *control, struct ast_bridge *bridge)
Remove a channel from the bridge.
Definition control.c:1483
struct ast_bridge * stasis_app_get_bridge(struct stasis_app_control *control)
Gets the bridge currently associated with a control object.
Definition control.c:983

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_no_content(), ast_log, control_list_create(), find_bridge(), LOG_WARNING, NULL, RAII_VAR, stasis_app_control_remove_channel_from_bridge(), and stasis_app_get_bridge().

Referenced by ast_ari_bridges_remove_channel_cb().

◆ ast_ari_bridges_remove_channel_parse_body()

int ast_ari_bridges_remove_channel_parse_body ( struct ast_json body,
struct ast_ari_bridges_remove_channel_args args 
)

Body parsing function for /bridges/{bridgeId}/removeChannel.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 990 of file res_ari_bridges.c.

993{
994 struct ast_json *field;
995 /* Parse query parameters out of it */
996 field = ast_json_object_get(body, "channel");
997 if (field) {
998 /* If they were silly enough to both pass in a query param and a
999 * JSON body, free up the query value.
1000 */
1001 ast_free(args->channel);
1002 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1003 /* Multiple param passed as array */
1004 size_t i;
1005 args->channel_count = ast_json_array_size(field);
1006 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
1007
1008 if (!args->channel) {
1009 return -1;
1010 }
1011
1012 for (i = 0; i < args->channel_count; ++i) {
1013 args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
1014 }
1015 } else {
1016 /* Multiple param passed as single value */
1017 args->channel_count = 1;
1018 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
1019 if (!args->channel) {
1020 return -1;
1021 }
1022 args->channel[0] = ast_json_string_get(field);
1023 }
1024 }
1025 return 0;
1026}

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_bridges_remove_channel_cb().

◆ ast_ari_bridges_set_bridge_var()

void ast_ari_bridges_set_bridge_var ( struct ast_variable headers,
struct ast_ari_bridges_set_bridge_var_args args,
struct ast_ari_response response 
)

Set the value of a bridge variable or function.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1397 of file resource_bridges.c.

1400{
1401 struct ast_bridge *bridge;
1402 char buf[strlen(args->variable) + 1];
1403 char *variable;
1404
1405 if (ast_strlen_zero(args->variable)) {
1406 ast_ari_response_error(response, 400, "Bad Request",
1407 "Variable name is required");
1408 return;
1409 }
1410
1411 bridge = find_bridge(response, args->bridge_id);
1412 if (!bridge) {
1413 return;
1414 }
1415 ao2_ref(bridge, -1);
1416
1417 strcpy(buf, args->variable);
1418 /* Strip whitespace from the variable name */
1419 variable = ast_strip(buf);
1420
1421 if (stasis_app_bridge_set_var_reportable(args->bridge_id, variable, args->value,
1422 args->report_events)) {
1423 ast_ari_response_error(response, 400, "Bad Request",
1424 "Failed to execute function");
1425 return;
1426 }
1427
1429}
int stasis_app_bridge_set_var_reportable(const char *bridge_id, const char *variable, const char *value, int report_events)
Set or clear a variable on a bridge and control ARI event reporting for it.
Definition res_stasis.c:923

References ao2_ref, args, ast_ari_response_error(), ast_ari_response_no_content(), ast_strip(), ast_strlen_zero(), buf, find_bridge(), and stasis_app_bridge_set_var_reportable().

Referenced by ast_ari_bridges_set_bridge_var_cb().

◆ ast_ari_bridges_set_bridge_var_parse_body()

int ast_ari_bridges_set_bridge_var_parse_body ( struct ast_json body,
struct ast_ari_bridges_set_bridge_var_args args 
)

Body parsing function for /bridges/{bridgeId}/variable.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 487 of file res_ari_bridges.c.

490{
491 struct ast_json *field;
492 /* Parse query parameters out of it */
493 field = ast_json_object_get(body, "variable");
494 if (field) {
495 args->variable = ast_json_string_get(field);
496 }
497 field = ast_json_object_get(body, "value");
498 if (field) {
499 args->value = ast_json_string_get(field);
500 }
501 field = ast_json_object_get(body, "report_events");
502 if (field) {
503 args->report_events = ast_json_is_true(field);
504 }
505 return 0;
506}

References args, ast_json_is_true(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_bridges_set_bridge_var_cb().

◆ ast_ari_bridges_set_bridge_vars()

void ast_ari_bridges_set_bridge_vars ( struct ast_variable headers,
struct ast_ari_bridges_set_bridge_vars_args args,
struct ast_ari_response response 
)

Set the values of multiple bridge variables or functions.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1528 of file resource_bridges.c.

1531{
1532 struct ast_json *json_variables;
1533 struct ast_variable *var;
1534 RAII_VAR(struct ast_variable *, variables, NULL, ast_variables_destroy);
1535 RAII_VAR(struct ast_variable *, report_event_variables, NULL, ast_variables_destroy);
1536 RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
1537
1538 ast_assert(response != NULL);
1539
1540 if (!args->variables) {
1542 response, 400, "Bad Request",
1543 "The 'variables' field is required");
1544 return;
1545 }
1546
1547 bridge = stasis_app_bridge_find_by_id(args->bridge_id);
1548 if (!bridge) {
1550 response, 404, "Bridge Not Found",
1551 "Provided bridge was not found");
1552 return;
1553 }
1554
1555 json_variables = ast_json_object_get(args->variables, "variables");
1556 if (!json_variables || ast_json_typeof(json_variables) != AST_JSON_OBJECT) {
1558 response, 400, "Bad Request",
1559 "The 'variables' field must be a JSON object");
1560 return;
1561 }
1562
1563 if (json_to_ast_variables(response, json_variables, &variables,
1564 &report_event_variables)) {
1565 return;
1566 }
1567
1568 for (var = variables; var; var = var->next) {
1569 int report_events = 0;
1570 struct ast_variable *report_var;
1571 char buf[strlen(var->name) + 1];
1572 char *variable;
1573 strcpy(buf, var->name);
1574 /* Strip whitespace from the variable name */
1575 variable = ast_strip(buf);
1576
1577 /* See if the variable is in the report event list */
1578 for (report_var = report_event_variables; report_var;
1579 report_var = report_var->next) {
1580 if (!strcmp(report_var->name, var->name)) {
1581 report_events = 1;
1582 break;
1583 }
1584 }
1585
1586 if (stasis_app_bridge_set_var_reportable(args->bridge_id, variable, var->value,
1587 report_events)) {
1589 response, 400, "Bad Request",
1590 "Failed to execute function");
1591 return;
1592 }
1593 }
1594
1596}
@ AST_JSON_OBJECT
Definition json.h:164

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_no_content(), ast_assert, AST_JSON_OBJECT, ast_json_object_get(), ast_json_typeof(), ast_strip(), ast_variables_destroy(), buf, json_to_ast_variables(), ast_variable::name, ast_variable::next, NULL, RAII_VAR, stasis_app_bridge_find_by_id(), stasis_app_bridge_set_var_reportable(), and var.

Referenced by ast_ari_bridges_set_bridge_vars_cb().

◆ ast_ari_bridges_set_bridge_vars_parse_body()

int ast_ari_bridges_set_bridge_vars_parse_body ( struct ast_json body,
struct ast_ari_bridges_set_bridge_vars_args args 
)

Body parsing function for /bridges/{bridgeId}/variables.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 738 of file res_ari_bridges.c.

741{
742 /* Parse query parameters out of it */
743 return 0;
744}

◆ ast_ari_bridges_set_video_source()

void ast_ari_bridges_set_video_source ( struct ast_variable headers,
struct ast_ari_bridges_set_video_source_args args,
struct ast_ari_response response 
)

Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 1303 of file resource_bridges.c.

1305{
1306 struct ast_bridge *bridge;
1307 struct stasis_app_control *control;
1308
1309 bridge = find_bridge(response, args->bridge_id);
1310 if (!bridge) {
1311 return;
1312 }
1313
1314 control = find_channel_control(response, args->channel_id);
1315 if (!control) {
1316 ao2_ref(bridge, -1);
1317 return;
1318 }
1319
1320 if (stasis_app_get_bridge(control) != bridge) {
1321 ast_ari_response_error(response, 422,
1322 "Unprocessable Entity",
1323 "Channel not in this bridge");
1324 ao2_ref(bridge, -1);
1325 ao2_ref(control, -1);
1326 return;
1327 }
1328
1331
1332 ao2_ref(bridge, -1);
1333 ao2_ref(control, -1);
1334
1336}
void __ao2_cleanup(void *obj)
Definition astobj2.c:677
static struct stasis_app_control * find_channel_control(struct ast_ari_response *response, const char *channel_id)
Finds the control object for a channel, filling the response with an error, if appropriate.
static int bridge_set_video_source_cb(struct stasis_app_control *control, struct ast_channel *chan, void *data)
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.
Definition control.c:950
struct ast_bridge * bridge
Definition control.c:67

References __ao2_cleanup(), ao2_bump, ao2_ref, args, ast_ari_response_error(), ast_ari_response_no_content(), stasis_app_control::bridge, bridge_set_video_source_cb(), find_bridge(), find_channel_control(), stasis_app_get_bridge(), and stasis_app_send_command().

Referenced by ast_ari_bridges_set_video_source_cb().

◆ ast_ari_bridges_start_moh()

void ast_ari_bridges_start_moh ( struct ast_variable headers,
struct ast_ari_bridges_start_moh_args args,
struct ast_ari_response response 
)

Play music on hold to a bridge or change the MOH class that is playing.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 899 of file resource_bridges.c.

902{
903 RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
904 struct ast_channel *moh_channel;
905 const char *moh_class = args->moh_class;
906
907 if (!bridge) {
908 /* The response is provided by find_bridge() */
909 return;
910 }
911
913 if (!moh_channel) {
915 return;
916 }
917
918 ast_moh_start(moh_channel, moh_class, NULL);
919 ast_channel_cleanup(moh_channel);
920
922
923}
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition channel.h:3030
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition channel.c:7802
struct ast_channel * stasis_app_bridge_moh_channel(struct ast_bridge *bridge)
Finds or creates an announcer channel in a bridge that can play music on hold.
Definition res_stasis.c:655
struct ast_bridge * bridge

References ao2_cleanup, args, ast_ari_response_alloc_failed(), ast_ari_response_no_content(), ast_channel_cleanup, ast_moh_start(), ast_channel::bridge, find_bridge(), NULL, RAII_VAR, and stasis_app_bridge_moh_channel().

Referenced by ast_ari_bridges_start_moh_cb().

◆ ast_ari_bridges_start_moh_parse_body()

int ast_ari_bridges_start_moh_parse_body ( struct ast_json body,
struct ast_ari_bridges_start_moh_args args 
)

Body parsing function for /bridges/{bridgeId}/moh.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1268 of file res_ari_bridges.c.

1271{
1272 struct ast_json *field;
1273 /* Parse query parameters out of it */
1274 field = ast_json_object_get(body, "mohClass");
1275 if (field) {
1276 args->moh_class = ast_json_string_get(field);
1277 }
1278 return 0;
1279}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_bridges_start_moh_cb().

◆ ast_ari_bridges_stop_moh()

void ast_ari_bridges_stop_moh ( struct ast_variable headers,
struct ast_ari_bridges_stop_moh_args args,
struct ast_ari_response response 
)

Stop playing music on hold to a bridge.

This will only stop music on hold being played via POST bridges/{bridgeId}/moh.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 925 of file resource_bridges.c.

928{
929 RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
930
931 if (!bridge) {
932 /* the response is provided by find_bridge() */
933 return;
934 }
935
936 if (stasis_app_bridge_moh_stop(bridge)) {
938 response, 409, "Conflict",
939 "Bridge isn't playing music");
940 return;
941 }
942
944}
int stasis_app_bridge_moh_stop(struct ast_bridge *bridge)
Breaks down MOH channels playing on the bridge created by stasis_app_bridge_moh_channel.
Definition res_stasis.c:675

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_no_content(), ast_channel::bridge, find_bridge(), RAII_VAR, and stasis_app_bridge_moh_stop().

Referenced by ast_ari_bridges_stop_moh_cb().