| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
#include "asterisk.h"#include <pthread.h>#include "asterisk/astobj2.h"#include "asterisk/strings.h"#include "asterisk/res_aeap.h"#include "asterisk/res_aeap_message.h"#include "logger.h"#include "transaction.h"#include "transport.h"
Go to the source code of this file.
| Data Structures | |
| struct | aeap_user_data | 
| struct | ast_aeap | 
| Macros | |
| #define | AEAP_RECV_SIZE 32768 | 
| #define | USER_DATA_BUCKETS 11 | 
| Functions | |
| static void | aeap_destructor (void *obj) | 
| static void * | aeap_receive (void *data) | 
| static int | aeap_send (struct ast_aeap *aeap, const void *buf, uintmax_t size, enum AST_AEAP_DATA_TYPE type) | 
| static struct aeap_user_data * | aeap_user_data_create (const char *id, void *obj, ast_aeap_user_obj_cleanup cleanup) | 
| AO2_STRING_FIELD_CMP_FN (aeap_user_data, id) | |
| AO2_STRING_FIELD_HASH_FN (aeap_user_data, id) | |
| int | ast_aeap_connect (struct ast_aeap *aeap, const char *url, const char *protocol, int timeout) | 
| Connect to an external application. | |
| struct ast_aeap * | ast_aeap_create (const char *transport_type, const struct ast_aeap_params *params) | 
| Create an Asterisk external application object. | |
| 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. | |
| int | ast_aeap_disconnect (struct ast_aeap *aeap) | 
| Disconnect an Asterisk external application object. | |
| int | ast_aeap_send_binary (struct ast_aeap *aeap, const void *buf, uintmax_t size) | 
| Send a binary data to an external application. | |
| int | ast_aeap_send_msg (struct ast_aeap *aeap, struct ast_aeap_message *msg) | 
| Send a message to an external application. | |
| 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. | |
| void * | ast_aeap_user_data_object_by_id (struct ast_aeap *aeap, const char *id) | 
| Retrieve a registered user data object by its id. | |
| 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. | |
| void | ast_aeap_user_data_unregister (struct ast_aeap *aeap, const char *id) | 
| Un-register a user data object. | |
| static void | raise_msg (struct ast_aeap *aeap, const void *buf, intmax_t size, enum AST_AEAP_DATA_TYPE serial_type) | 
| static int | raise_msg_handler (struct ast_aeap *aeap, const struct ast_aeap_message_handler *handlers, size_t size, struct ast_aeap_message *msg, void *data) | 
| static int | tsx_end (void *obj, void *arg, int flags) | 
| 
 | static | 
Definition at line 67 of file aeap.c.
References aeap_transport_destroy(), ao2_callback, ao2_cleanup, ast_aeap_disconnect(), NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, ast_aeap::transactions, ast_aeap::transport, tsx_end(), and ast_aeap::user_data.
Referenced by ast_aeap_create().
| 
 | static | 
Definition at line 269 of file aeap.c.
References aeap_error, AEAP_RECV_SIZE, aeap_transport_is_connected(), aeap_transport_read(), ao2_lock, ao2_unlock, AST_AEAP_DATA_TYPE_BINARY, AST_AEAP_DATA_TYPE_STRING, ast_aeap_disconnect(), ast_calloc, ast_debug, ast_free, AST_PTHREADT_NULL, buf, NULL, ast_aeap_params::on_binary, ast_aeap_params::on_error, ast_aeap_params::on_string, ast_aeap::params, raise_msg(), ast_aeap::read_thread_id, and ast_aeap::transport.
Referenced by ast_aeap_connect().
| 
 | static | 
Definition at line 404 of file aeap.c.
References aeap_error, aeap_transport_write(), buf, NULL, ast_aeap::transport, and type.
Referenced by ast_aeap_send_binary(), and ast_aeap_send_msg().
| 
 | static | 
Definition at line 127 of file aeap.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_t_alloc_options, ast_assert, cleanup(), aeap_user_data::id, NULL, and aeap_user_data::obj.
Referenced by ast_aeap_user_data_register().
| AO2_STRING_FIELD_CMP_FN | ( | aeap_user_data | , | 
| id | |||
| ) | 
| AO2_STRING_FIELD_HASH_FN | ( | aeap_user_data | , | 
| id | |||
| ) | 
| 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(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| 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(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and speech_aeap_send_request().
| 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(), AST_TEST_DEFINE(), 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(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| 
 | static | 
Definition at line 236 of file aeap.c.
References aeap_transaction::aeap, aeap_transaction_cancel_timer(), aeap_transaction_end(), aeap_transaction_get(), aeap_transaction_user_obj(), ao2_ref, ast_aeap_message_deserialize(), ast_aeap_message_id(), ast_aeap_message_is_request(), ast_aeap_message_is_response(), ast_aeap_message_serial_type(), buf, ast_aeap_params::msg_type, NULL, ast_aeap::params, raise_msg_handler(), ast_aeap_params::request_handlers, ast_aeap_params::request_handlers_size, ast_aeap_params::response_handlers, ast_aeap_params::response_handlers_size, and ast_aeap::transactions.
Referenced by aeap_receive().
| 
 | static | 
Definition at line 194 of file aeap.c.
References aeap_error, ast_aeap_message_create_error(), ast_aeap_message_error_msg(), ast_aeap_message_id(), ast_aeap_message_is_named(), ast_aeap_message_name(), ast_aeap_send_msg(), ast_strlen_zero(), ast_aeap_params::emit_error, handlers, ast_aeap_params::msg_type, name, NULL, ast_aeap_message_handler::on_message, and ast_aeap::params.
Referenced by raise_msg().
| 
 | static | 
Definition at line 60 of file aeap.c.
References aeap_transaction_end().
Referenced by aeap_destructor().