return ast_ari_validate_dialplan_cep;
}
-int ast_ari_validate_external_media(struct ast_json *json)
-{
- int res = 1;
- struct ast_json_iter *iter;
- int has_channel = 0;
-
- for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
- if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
- int prop_is_valid;
- has_channel = 1;
- prop_is_valid = ast_ari_validate_channel(
- ast_json_object_iter_value(iter));
- if (!prop_is_valid) {
- ast_log(LOG_ERROR, "ARI ExternalMedia field channel failed validation\n");
- res = 0;
- }
- } else
- if (strcmp("local_address", ast_json_object_iter_key(iter)) == 0) {
- int prop_is_valid;
- prop_is_valid = ast_ari_validate_string(
- ast_json_object_iter_value(iter));
- if (!prop_is_valid) {
- ast_log(LOG_ERROR, "ARI ExternalMedia field local_address failed validation\n");
- res = 0;
- }
- } else
- if (strcmp("local_port", ast_json_object_iter_key(iter)) == 0) {
- int prop_is_valid;
- prop_is_valid = ast_ari_validate_int(
- ast_json_object_iter_value(iter));
- if (!prop_is_valid) {
- ast_log(LOG_ERROR, "ARI ExternalMedia field local_port failed validation\n");
- res = 0;
- }
- } else
- {
- ast_log(LOG_ERROR,
- "ARI ExternalMedia has undocumented field %s\n",
- ast_json_object_iter_key(iter));
- res = 0;
- }
- }
-
- if (!has_channel) {
- ast_log(LOG_ERROR, "ARI ExternalMedia missing required field channel\n");
- res = 0;
- }
-
- return res;
-}
-
-ari_validator ast_ari_validate_external_media_fn(void)
-{
- return ast_ari_validate_external_media;
-}
-
int ast_ari_validate_rtpstat(struct ast_json *json)
{
int res = 1;
*/
ari_validator ast_ari_validate_dialplan_cep_fn(void);
-/*!
- * \brief Validator for ExternalMedia.
- *
- * ExternalMedia session.
- *
- * \param json JSON object to validate.
- * \returns True (non-zero) if valid.
- * \returns False (zero) if invalid.
- */
-int ast_ari_validate_external_media(struct ast_json *json);
-
-/*!
- * \brief Function pointer to ast_ari_validate_external_media().
- *
- * See \ref ast_ari_model_validators.h for more details.
- */
-ari_validator ast_ari_validate_external_media_fn(void);
-
/*!
* \brief Validator for RTPstat.
*
* - context: string (required)
* - exten: string (required)
* - priority: long (required)
- * ExternalMedia
- * - channel: Channel (required)
- * - local_address: string
- * - local_port: int
* RTPstat
* - channel_uniqueid: string (required)
* - local_maxjitter: double
size_t endpoint_len;
char *endpoint;
struct ast_channel *chan;
- struct ast_json *json_chan;
struct varshead *vars;
endpoint_len = strlen("UnicastRTP/") + strlen(args->external_host) + 1;
return;
}
- /*
- * At this point, response->message contains a channel object so we
- * need to save it then create a new ExternalMedia object and put the
- * channel in it.
- */
- json_chan = response->message;
- response->message = ast_json_object_create();
- if (!response->message) {
- ast_channel_unref(chan);
- ast_json_unref(json_chan);
- ast_ari_response_alloc_failed(response);
- return;
- }
-
- ast_json_object_set(response->message, "channel", json_chan);
- /*
- * At the time the channel snapshot was taken the channel variables might
- * not have been set so we try to grab them directly from the channel.
- */
ast_channel_lock(chan);
vars = ast_channel_varshead(chan);
if (vars && !AST_LIST_EMPTY(vars)) {
- struct ast_var_t *variables;
-
- /* Put them all on the channel object */
- ast_json_object_set(json_chan, "channelvars", ast_json_channel_vars(vars));
- /* Grab out the local address and port */
- AST_LIST_TRAVERSE(vars, variables, entries) {
- if (!strcmp("UNICASTRTP_LOCAL_ADDRESS", ast_var_name(variables))) {
- ast_json_object_set(response->message, "local_address",
- ast_json_string_create(ast_var_value(variables)));
- }
- else if (!strcmp("UNICASTRTP_LOCAL_PORT", ast_var_name(variables))) {
- ast_json_object_set(response->message, "local_port",
- ast_json_integer_create(strtol(ast_var_value(variables), NULL, 10)));
- }
- }
+ ast_json_object_set(response->message, "channelvars", ast_json_channel_vars(vars));
}
ast_channel_unlock(chan);
ast_channel_unref(chan);
break;
default:
if (200 <= code && code <= 299) {
- is_valid = ast_ari_validate_external_media(
+ is_valid = ast_ari_validate_channel(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/externalMedia\n", code);
"summary": "Start an External Media session.",
"notes": "Create a channel to an External Media source/sink.",
"nickname": "externalMedia",
- "responseClass": "ExternalMedia",
+ "responseClass": "Channel",
"parameters": [
{
"name": "channelId",
"description": "Channel variables"
}
}
- },
- "ExternalMedia": {
- "id": "ExternalMedia",
- "description": "ExternalMedia session.",
- "properties": {
- "channel": {
- "required": true,
- "type": "Channel",
- "description": "The Asterisk channel representing the external media"
- },
- "local_address": {
- "required": false,
- "type": "string",
- "description": "The local ip address used"
- },
- "local_port": {
- "required": false,
- "type": "int",
- "description": "The local ip port used"
- }
- }
}
}
}