diff --git a/res/ari/ari_model_validators.c b/res/ari/ari_model_validators.c index 3d63f5317f..8910bbb94a 100644 --- a/res/ari/ari_model_validators.c +++ b/res/ari/ari_model_validators.c @@ -1385,62 +1385,6 @@ ari_validator ast_ari_validate_dialplan_cep_fn(void) 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; diff --git a/res/ari/ari_model_validators.h b/res/ari/ari_model_validators.h index 53a85739cb..f9285b43ce 100644 --- a/res/ari/ari_model_validators.h +++ b/res/ari/ari_model_validators.h @@ -477,24 +477,6 @@ int ast_ari_validate_dialplan_cep(struct ast_json *json); */ 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. * @@ -1540,10 +1522,6 @@ ari_validator ast_ari_validate_application_fn(void); * - 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 diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c index 0fd2d691af..81a902c3e8 100644 --- a/res/ari/resource_channels.c +++ b/res/ari/resource_channels.c @@ -2064,7 +2064,6 @@ static void external_media_rtp_udp(struct ast_ari_channels_external_media_args * 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; @@ -2093,43 +2092,10 @@ static void external_media_rtp_udp(struct ast_ari_channels_external_media_args * 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); diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c index 27d9deb8cf..f938e14814 100644 --- a/res/res_ari_channels.c +++ b/res/res_ari_channels.c @@ -2918,7 +2918,7 @@ static void ast_ari_channels_external_media_cb( 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); diff --git a/rest-api/api-docs/channels.json b/rest-api/api-docs/channels.json index 53e6e9de3f..94afb277ab 100644 --- a/rest-api/api-docs/channels.json +++ b/rest-api/api-docs/channels.json @@ -1765,7 +1765,7 @@ "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", @@ -2166,27 +2166,6 @@ "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" - } - } } } }