39#define ADDR "127.0.0.1:8088"
57#define TEST_SPEECH_RESULTS_TEXT "foo"
58#define TEST_SPEECH_RESULTS_SCORE 7
59#define TEST_SPEECH_RESULTS_GRAMMAR "bar"
60#define TEST_SPEECH_RESULTS_BEST 1
72 if (!strcmp(param,
"results")) {
129 if (!strcmp(
name,
"setup")) {
131 }
else if (!strcmp(
name,
"get")) {
133 }
else if (!strcmp(
name,
"set")) {
179 uint64_t payload_len;
196 ast_debug(3,
"payload=%.*s\n", (
int)payload_len, payload);
219 info->name = __func__;
220 info->explicit_only = 0;
221 info->category =
"/res/aeap/speech/";
222 info->summary =
"test the speech AEAP interface";
243 ast_test_validate_cleanup(
test, !strcmp(
buf,
"bar"), res,
cleanup);
264 if (!(
http_server = ast_http_test_server_get(
"aeap transport http server",
NULL))) {
286 .
requires =
"res_speech_aeap",
Asterisk main include file. File version handling, generic pbx functions.
Generic File Format Support. Should be included by clients of the file handling routines....
Support for Private Asterisk HTTP Servers.
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
int ast_websocket_remove_protocol(const char *name, ast_websocket_callback callback)
Remove a sub-protocol handler from the default /ws server.
int ast_websocket_read(struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented)
Read a WebSocket frame and handle it.
int ast_websocket_wait_for_input(struct ast_websocket *session, int timeout)
Wait for the WebSocket session to be ready to be read.
ast_websocket_opcode
WebSocket operation codes.
@ AST_WEBSOCKET_OPCODE_BINARY
@ AST_WEBSOCKET_OPCODE_CLOSE
@ AST_WEBSOCKET_OPCODE_TEXT
void ast_websocket_unref(struct ast_websocket *session)
Decrease the reference count for a WebSocket session.
int ast_websocket_write_string(struct ast_websocket *ws, const char *buf)
Construct and transmit a WebSocket frame containing string data.
int ast_websocket_fd(struct ast_websocket *session)
Get the file descriptor for a WebSocket session.
int ast_websocket_write(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size)
Construct and transmit a WebSocket frame.
int ast_websocket_add_protocol(const char *name, ast_websocket_callback callback)
Add a sub-protocol handler to the default /ws server.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk JSON abstraction layer.
#define ast_json_object_string_get(object, key)
Get a string field from a JSON object.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
struct ast_json * ast_json_load_buf(const char *buffer, size_t buflen, struct ast_json_error *error)
Parse buffer with known length into a JSON object or array.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static void * cleanup(void *unused)
Asterisk External Application Protocol API.
Asterisk External Application Protocol Message API.
Generic Speech Recognition API.
int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf)
Signal to the engine that DTMF was received.
int ast_speech_results_free(struct ast_speech_result *result)
Free a set of results.
void ast_speech_start(struct ast_speech *speech)
Indicate to the speech engine that audio is now going to start being written.
int ast_speech_change(struct ast_speech *speech, const char *name, const char *value)
Change an engine specific attribute.
struct ast_speech * ast_speech_new(const char *engine_name, const struct ast_format_cap *formats)
Create a new speech structure.
int ast_speech_destroy(struct ast_speech *speech)
Destroy a speech structure.
int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type)
Change the type of results we want.
int ast_speech_get_setting(struct ast_speech *speech, const char *name, char *buf, size_t len)
Get an engine specific attribute.
@ AST_SPEECH_RESULTS_TYPE_NBEST
struct ast_speech_result * ast_speech_results_get(struct ast_speech *speech)
Get speech recognition results.
Abstract JSON element (object, array, string, int, ...).
struct ast_speech_result * results
Structure for variables, used for configurations and for channel variables.
Structure definition for session.
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
#define TEST_SPEECH_RESULTS_SCORE
static void speech_test_server_cb(struct ast_websocket *ws, struct ast_variable *parameters, struct ast_variable *headers)
static int speech_test_server_handle_request(struct ast_websocket *ws, const void *buf, uint64_t size)
#define TEST_SPEECH_RESULTS_TEXT
static int speech_test_server_get(struct ast_json *req, struct ast_json *resp)
AST_TEST_DEFINE(res_speech_aeap_test)
#define TEST_SPEECH_RESULTS_GRAMMAR
static int speech_test_server_setup(struct ast_json *req, struct ast_json *resp)
#define TEST_SPEECH_RESULTS_BEST
static int load_module(void)
static int unload_module(void)
static struct ast_http_server * http_server
static int speech_test_server_set(struct ast_json *req, struct ast_json *resp)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_fd_set_flags(fd, flags)
Set flags on the given file descriptor.