mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
feat: AudioSocket channel, application, and ARI support.
This commit adds support for [AudioSocket]( https://wiki.asterisk.org/wiki/display/AST/AudioSocket), a very simple bidirectional audio streaming protocol. There are both channel and application interfaces. A description of the protocol can be found on the above referenced GitHub page. A short talk about the reasons and implementation can be found on [YouTube](https://www.youtube.com/watch?v=tjduXbZZEgI), from CommCon 2019. ARI support has also been added via the existing "externalMedia" ARI functionality. The UUID is specified using the arbitrary "data" field. ASTERISK-28484 #close Change-Id: Ie866e6c4fa13178ec76f2a6971ad3590a3a588b5
This commit is contained in:
@@ -2101,6 +2101,51 @@ static void external_media_rtp_udp(struct ast_ari_channels_external_media_args *
|
||||
ast_channel_unref(chan);
|
||||
}
|
||||
|
||||
static void external_media_audiosocket_tcp(struct ast_ari_channels_external_media_args *args,
|
||||
struct ast_variable *variables,
|
||||
struct ast_ari_response *response)
|
||||
{
|
||||
size_t endpoint_len;
|
||||
char *endpoint;
|
||||
struct ast_channel *chan;
|
||||
struct varshead *vars;
|
||||
|
||||
endpoint_len = strlen("AudioSocket/") + strlen(args->external_host) + 1 + strlen(args->data) + 1;
|
||||
endpoint = ast_alloca(endpoint_len);
|
||||
/* The UUID is stored in the arbitrary data field */
|
||||
snprintf(endpoint, endpoint_len, "AudioSocket/%s/%s", args->external_host, args->data);
|
||||
|
||||
chan = ari_channels_handle_originate_with_id(
|
||||
endpoint,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
args->app,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
variables,
|
||||
args->channel_id,
|
||||
NULL,
|
||||
NULL,
|
||||
args->format,
|
||||
response);
|
||||
ast_variables_destroy(variables);
|
||||
|
||||
if (!chan) {
|
||||
return;
|
||||
}
|
||||
|
||||
ast_channel_lock(chan);
|
||||
vars = ast_channel_varshead(chan);
|
||||
if (vars && !AST_LIST_EMPTY(vars)) {
|
||||
ast_json_object_set(response->message, "channelvars", ast_json_channel_vars(vars));
|
||||
}
|
||||
ast_channel_unlock(chan);
|
||||
ast_channel_unref(chan);
|
||||
}
|
||||
|
||||
#include "asterisk/config.h"
|
||||
#include "asterisk/netsock2.h"
|
||||
|
||||
@@ -2161,6 +2206,8 @@ void ast_ari_channels_external_media(struct ast_variable *headers,
|
||||
|
||||
if (strcasecmp(args->encapsulation, "rtp") == 0 && strcasecmp(args->transport, "udp") == 0) {
|
||||
external_media_rtp_udp(args, variables, response);
|
||||
} else if (strcasecmp(args->encapsulation, "audiosocket") == 0 && strcasecmp(args->transport, "tcp") == 0) {
|
||||
external_media_audiosocket_tcp(args, variables, response);
|
||||
} else {
|
||||
ast_ari_response_error(
|
||||
response, 501, "Not Implemented",
|
||||
|
@@ -844,6 +844,8 @@ struct ast_ari_channels_external_media_args {
|
||||
const char *format;
|
||||
/*! External media direction */
|
||||
const char *direction;
|
||||
/*! An arbitrary data field */
|
||||
const char *data;
|
||||
};
|
||||
/*!
|
||||
* \brief Body parsing function for /channels/externalMedia.
|
||||
|
Reference in New Issue
Block a user