Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Asterisk External Application Protocol API. More...
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | ast_aeap_message_handler |
An Asterisk external application message handler. More... | |
struct | ast_aeap_params |
Callbacks and other parameters used by an Asterisk external application object. More... | |
struct | ast_aeap_tsx_params |
Parameters to be used when sending a transaction based message. More... | |
Macros | |
#define | AEAP_CONFIG_CLIENT "client" |
Typedefs | |
typedef int(* | ast_aeap_on_message) (struct ast_aeap *aeap, struct ast_aeap_message *message, void *obj) |
Event raised when a message is received. More... | |
typedef void(* | ast_aeap_on_timeout) (struct ast_aeap *aeap, struct ast_aeap_message *message, void *obj) |
Event raised when a sent message does not receive a reply within a specified time interval. More... | |
typedef void(* | ast_aeap_user_obj_cleanup) (void *obj) |
Callback to cleanup a user object. More... | |
Enumerations | |
enum | AST_AEAP_DATA_TYPE { AST_AEAP_DATA_TYPE_NONE , AST_AEAP_DATA_TYPE_BINARY , AST_AEAP_DATA_TYPE_STRING } |
Supported Asterisk external application data types. More... | |
Functions | |
const struct ast_format_cap * | ast_aeap_client_config_codecs (const struct ast_aeap_client_config *cfg) |
Retrieve codec capabilities from the configuration. More... | |
int | ast_aeap_client_config_has_protocol (const struct ast_aeap_client_config *cfg, const char *protocol) |
Check a given protocol against that in an Asterisk external application configuration. More... | |
struct ao2_container * | ast_aeap_client_configs_get (const char *protocol) |
Retrieve a listing of all client configuration objects by protocol. More... | |
int | ast_aeap_connect (struct ast_aeap *aeap, const char *url, const char *protocol, int timeout) |
Connect to an external application. More... | |
struct ast_aeap * | ast_aeap_create (const char *type, const struct ast_aeap_params *params) |
Create an Asterisk external application object. More... | |
struct ast_aeap * | ast_aeap_create_and_connect (const char *type, const struct ast_aeap_params *params, const char *url, const char *protocol, int timeout) |
Create and connect to an Asterisk external application. More... | |
struct ast_aeap * | ast_aeap_create_and_connect_by_id (const char *id, const struct ast_aeap_params *params, int timeout) |
Create and connect to an Asterisk external application by sorcery id. More... | |
struct ast_aeap * | ast_aeap_create_by_id (const char *id, const struct ast_aeap_params *params) |
Create an Asterisk external application object by sorcery id. More... | |
struct ast_variable * | ast_aeap_custom_fields_get (const char *id) |
Retrieve a list of custom configuration fields. More... | |
int | ast_aeap_disconnect (struct ast_aeap *aeap) |
Disconnect an Asterisk external application object. More... | |
int | ast_aeap_send_binary (struct ast_aeap *aeap, const void *buf, uintmax_t size) |
Send a binary data to an external application. More... | |
int | ast_aeap_send_msg (struct ast_aeap *aeap, struct ast_aeap_message *msg) |
Send a message to an external application. More... | |
int | ast_aeap_send_msg_tsx (struct ast_aeap *aeap, struct ast_aeap_tsx_params *params) |
Send a transaction based message to an external application using the given parameters. More... | |
struct ast_sorcery * | ast_aeap_sorcery (void) |
Retrieve the AEAP sorcery object. More... | |
void * | ast_aeap_user_data_object_by_id (struct ast_aeap *aeap, const char *id) |
Retrieve a registered user data object by its id. More... | |
int | ast_aeap_user_data_register (struct ast_aeap *aeap, const char *id, void *obj, ast_aeap_user_obj_cleanup cleanup) |
Register a user data object. More... | |
void | ast_aeap_user_data_unregister (struct ast_aeap *aeap, const char *id) |
Un-register a user data object. More... | |
Asterisk External Application Protocol API.
Definition in file res_aeap.h.
#define AEAP_CONFIG_CLIENT "client" |
Definition at line 35 of file res_aeap.h.
typedef int(* ast_aeap_on_message) (struct ast_aeap *aeap, struct ast_aeap_message *message, void *obj) |
Event raised when a message is received.
aeap | An Asterisk external application object |
message | The received message |
obj | Associated user object |
Definition at line 101 of file res_aeap.h.
typedef void(* ast_aeap_on_timeout) (struct ast_aeap *aeap, struct ast_aeap_message *message, void *obj) |
Event raised when a sent message does not receive a reply within a specified time interval.
aeap | An Asterisk external application object |
message | The message sent that received no response |
obj | Associated user object |
Definition at line 123 of file res_aeap.h.
typedef void(* ast_aeap_user_obj_cleanup) (void *obj) |
Callback to cleanup a user object.
obj | The user object |
Definition at line 130 of file res_aeap.h.
enum AST_AEAP_DATA_TYPE |
Supported Asterisk external application data types.
Enumerator | |
---|---|
AST_AEAP_DATA_TYPE_NONE | |
AST_AEAP_DATA_TYPE_BINARY | |
AST_AEAP_DATA_TYPE_STRING |
Definition at line 135 of file res_aeap.h.
const struct ast_format_cap * ast_aeap_client_config_codecs | ( | const struct ast_aeap_client_config * | cfg | ) |
Retrieve codec capabilities from the configuration.
cfg | A configuration object |
Definition at line 131 of file res_aeap.c.
References ast_aeap_client_config::codecs.
Referenced by load_engine().
int ast_aeap_client_config_has_protocol | ( | const struct ast_aeap_client_config * | cfg, |
const char * | protocol | ||
) |
Check a given protocol against that in an Asterisk external application configuration.
cfg | A configuration object |
protocol | The protocol to check |
Definition at line 136 of file res_aeap.c.
References ast_aeap_client_config::protocol.
Referenced by load_engine(), and unload_engine().
struct ao2_container * ast_aeap_client_configs_get | ( | const char * | protocol | ) |
Retrieve a listing of all client configuration objects by protocol.
protocol | An optional protocol to filter on (if NULL returns all client configs) |
Definition at line 142 of file res_aeap.c.
References AEAP_CONFIG_CLIENT, aeap_sorcery, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), ast_variable_new, ast_variables_destroy(), container, NULL, and var.
Referenced by client_config_show(), client_config_show_all(), load_module(), speech_observer_loaded(), and unload_module().
int ast_aeap_connect | ( | struct ast_aeap * | aeap, |
const char * | url, | ||
const char * | protocol, | ||
int | timeout | ||
) |
Connect to an external application.
aeap | An Asterisk external application object |
url | The url to connect to |
protocol | A protocol to use |
timeout | How long (in milliseconds) to attempt to connect (-1 equals infinite) |
Definition at line 338 of file aeap.c.
References aeap_error, aeap_receive(), aeap_transport_connect(), aeap_transport_is_connected(), ast_aeap_disconnect(), ast_pthread_create_background, errno, lock, NULL, ast_aeap::read_thread_id, SCOPED_AO2LOCK, ast_aeap::transport, and url.
Referenced by ast_aeap_create_and_connect().
struct ast_aeap * ast_aeap_create | ( | const char * | type, |
const struct ast_aeap_params * | params | ||
) |
Create an Asterisk external application object.
type | The type of underlying transport |
params | Callbacks and other parameters to use |
Definition at line 88 of file aeap.c.
References aeap_destructor(), aeap_error, aeap_transactions_create(), aeap_transport_create(), ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ast_log, AST_PTHREADT_NULL, LOG_ERROR, NULL, ast_aeap::params, ast_aeap::read_thread_id, ast_aeap::transactions, ast_aeap::transport, ast_aeap::user_data, and USER_DATA_BUCKETS.
Referenced by aeap_create(), and ast_aeap_create_and_connect().
struct ast_aeap * ast_aeap_create_and_connect | ( | const char * | type, |
const struct ast_aeap_params * | params, | ||
const char * | url, | ||
const char * | protocol, | ||
int | timeout | ||
) |
Create and connect to an Asterisk external application.
type | The type of client connection to make |
params | Callbacks and other parameters to use |
url | The url to connect to |
protocol | A protocol to use |
timeout | How long (in milliseconds) to attempt to connect (-1 equals infinite) |
Definition at line 363 of file aeap.c.
References ao2_ref, ast_aeap_connect(), ast_aeap_create(), NULL, ast_aeap::params, type, and url.
Referenced by aeap_create(), and AST_TEST_DEFINE().
struct ast_aeap * ast_aeap_create_and_connect_by_id | ( | const char * | id, |
const struct ast_aeap_params * | params, | ||
int | timeout | ||
) |
Create and connect to an Asterisk external application by sorcery id.
id | The sorcery id to lookup |
params | Callbacks and other parameters to use |
timeout | How long (in milliseconds) to attempt to connect (-1 equals infinite) |
Definition at line 322 of file res_aeap.c.
References aeap_create(), and ast_aeap::params.
Referenced by speech_aeap_engine_create().
struct ast_aeap * ast_aeap_create_by_id | ( | const char * | id, |
const struct ast_aeap_params * | params | ||
) |
Create an Asterisk external application object by sorcery id.
id | The sorcery id to lookup |
params | Callbacks and other parameters to use |
Definition at line 317 of file res_aeap.c.
References aeap_create(), and ast_aeap::params.
struct ast_variable * ast_aeap_custom_fields_get | ( | const char * | id | ) |
Retrieve a list of custom configuration fields.
id | configuration id/sorcery lookup key |
Definition at line 328 of file res_aeap.c.
References aeap_sorcery, ao2_ref, ast_log, ast_sorcery_objectset_create, client_config_get(), LOG_WARNING, and NULL.
Referenced by speech_aeap_engine_create().
int ast_aeap_disconnect | ( | struct ast_aeap * | aeap | ) |
Disconnect an Asterisk external application object.
aeap | An Asterisk external application object |
Definition at line 381 of file aeap.c.
References aeap_transport_disconnect(), ao2_lock, ao2_unlock, AST_PTHREADT_NULL, NULL, ast_aeap::read_thread_id, and ast_aeap::transport.
Referenced by aeap_destructor(), aeap_receive(), and ast_aeap_connect().
int ast_aeap_send_binary | ( | struct ast_aeap * | aeap, |
const void * | buf, | ||
uintmax_t | size | ||
) |
Send a binary data to an external application.
aeap | An Asterisk external application object |
buf | Binary data to send |
size | The size of the binary data |
Definition at line 434 of file aeap.c.
References aeap_send(), AST_AEAP_DATA_TYPE_BINARY, and buf.
Referenced by speech_aeap_engine_write().
int ast_aeap_send_msg | ( | struct ast_aeap * | aeap, |
struct ast_aeap_message * | msg | ||
) |
Send a message to an external application.
aeap | An Asterisk external application object |
msg | The message to send |
Definition at line 439 of file aeap.c.
References aeap_error, aeap_send(), ao2_ref, ast_aeap_message_serialize(), ast_free, buf, NULL, ast_aeap_message_type::serial_type, and ast_aeap_message::type.
Referenced by ast_aeap_send_msg_tsx(), handle_request_set(), and raise_msg_handler().
int ast_aeap_send_msg_tsx | ( | struct ast_aeap * | aeap, |
struct ast_aeap_tsx_params * | params | ||
) |
Send a transaction based message to an external application using the given parameters.
aeap | An Asterisk external application object |
params | (optional) Additional parameters to consider when sending. Heap allocation not required. |
Definition at line 464 of file aeap.c.
References aeap_transaction::aeap, aeap_error, aeap_transaction_create_and_add(), aeap_transaction_end(), aeap_transaction_params_cleanup(), aeap_transaction_result(), aeap_transaction_start(), ao2_bump, ao2_ref, ast_aeap_message_id(), ast_aeap_send_msg(), ast_aeap_tsx_params::msg, NULL, aeap_transaction::params, and ast_aeap::transactions.
Referenced by AST_TEST_DEFINE(), and speech_aeap_send_request().
struct ast_sorcery * ast_aeap_sorcery | ( | void | ) |
Retrieve the AEAP sorcery object.
Definition at line 67 of file res_aeap.c.
References aeap_sorcery.
Referenced by load_module(), and unload_module().
void * ast_aeap_user_data_object_by_id | ( | struct ast_aeap * | aeap, |
const char * | id | ||
) |
Retrieve a registered user data object by its id.
aeap | An Asterisk external application object |
id | The look up id for the object |
Definition at line 174 of file aeap.c.
References ao2_find, ao2_ref, NULL, aeap_user_data::obj, OBJ_SEARCH_KEY, and ast_aeap::user_data.
Referenced by ast_aeap_speech_on_error(), handle_msg(), handle_request_set(), handle_string(), and handle_timeout().
int ast_aeap_user_data_register | ( | struct ast_aeap * | aeap, |
const char * | id, | ||
void * | obj, | ||
ast_aeap_user_obj_cleanup | cleanup | ||
) |
Register a user data object.
aeap | An Asterisk external application object |
id | The look up id for the object |
obj | The user object to register |
cleanup | Optional user object clean up callback |
Definition at line 150 of file aeap.c.
References aeap_user_data_create(), ao2_link, ao2_ref, cleanup(), aeap_user_data::obj, and ast_aeap::user_data.
Referenced by AST_TEST_DEFINE(), and speech_aeap_engine_create().
void ast_aeap_user_data_unregister | ( | struct ast_aeap * | aeap, |
const char * | id | ||
) |
Un-register a user data object.
aeap | An Asterisk external application object |
id | The look up id for the object |
Definition at line 169 of file aeap.c.
References ao2_find, OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, and ast_aeap::user_data.
Referenced by AST_TEST_DEFINE().