ExternalMedia: Change return object from ExternalMedia to Channel

When we created the External Media addition to ARI we created an
ExternalMedia object to be returned from the channels/externalMedia
REST endpoint.  This object contained the channel object that was
created plus local_address and local_port attributes (which are
also in the Channel variables).  At the time, we thought that
creating an ExternalMedia object would give us more flexibility
in the future but as we created the sample speech to text
application, we discovered that it doesn't work so well with ARI
client libraries that a) don't have the ExternalMedia object
defined and/or b) can't promote the embedded channel structure
to a first-class Channel object.

This change causes the channels/externalMedia REST endpoint to
return a Channel object (like channels/create and channels/originate)
instead of the ExternalMedia object.

Change-Id: If280094debd35102cf21e0a31a5e0846fec14af9
This commit is contained in:
George Joseph
2019-10-18 05:36:12 -06:00
parent a339c3fdc5
commit bfd0e05e59
5 changed files with 3 additions and 136 deletions

View File

@@ -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;