FS-6450 [unimrcp] Update library

[apr] Backport APR_RING_FOREACH and APR_RING_FOREACH_SAFE macros to APR for unimrcp compatibility.

 [unimrcp] configure.gnu - need full path, not relative path for library paths

 [unimrcp] added uni_revision.h - couldn't get it to autogenerate from build

 [mod_unimrcp] add better logging and error checking on module load.  Currently dumps core on MRCPv1 TTS attempt

 [mod_unimrcp] don't configure MRCPv1 session with a connection agent- causes crash
This commit is contained in:
Chris Rienzo committed 2014-11-18 14:23:54 -05:00
1 parent f198d82bac
commit 8330336e9a
533 files changed
+16386 -18997

No files matched your search

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: demo_bypass_application.c 1474 2010-02-07 20:51:47Z achaloyan $
* $Id: demo_bypass_application.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
*/
/*
@@ -62,7 +62,9 @@ static const mrcp_app_message_dispatcher_t demo_application_dispatcher = {
demo_application_on_session_terminate,
demo_application_on_channel_add,
demo_application_on_channel_remove,
demo_application_on_message_receive
demo_application_on_message_receive,
NULL /* demo_application_on_terminate_event */,
NULL /* demo_application_on_resource_discover */
};
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: demo_discover_application.c 1474 2010-02-07 20:51:47Z achaloyan $
* $Id: demo_discover_application.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
*/
/*
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: demo_framework.c 1571 2010-03-07 20:33:39Z achaloyan $
* $Id: demo_framework.c 2233 2014-11-12 01:34:59Z achaloyan@gmail.com $
*/
#include <apr_hash.h>
@@ -118,9 +118,8 @@ apt_bool_t demo_framework_app_run(demo_framework_t *framework, const char *app_n
framework_task_data_t *framework_task_data = (framework_task_data_t*)task_msg->data;
task_msg->type = TASK_MSG_USER;
task_msg->sub_type = DEMO_CONSOLE_MSG_ID;
framework_task_data = (framework_task_data_t*) task_msg->data;
strcpy(framework_task_data->app_name,app_name);
strcpy(framework_task_data->profile_name,profile_name);
strncpy(framework_task_data->app_name,app_name,sizeof(framework_task_data->app_name)-1);
strncpy(framework_task_data->profile_name,profile_name,sizeof(framework_task_data->profile_name)-1);
framework_task_data->app_message = NULL;
framework_task_data->demo_application = NULL;
apt_task_msg_signal(task,task_msg);
@@ -237,7 +236,6 @@ static apt_bool_t demo_framework_message_handler(const mrcp_app_message_t *app_m
framework_task_data_t *framework_task_data = (framework_task_data_t*)task_msg->data;
task_msg->type = TASK_MSG_USER;
task_msg->sub_type = DEMO_APPLICATION_MSG_ID;
framework_task_data = (framework_task_data_t*) task_msg->data;
framework_task_data->app_message = app_message;
framework_task_data->demo_application = demo_application;
apt_task_msg_signal(task,task_msg);
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: demo_recog_application.c 1474 2010-02-07 20:51:47Z achaloyan $
* $Id: demo_recog_application.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
*/
/*
@@ -38,6 +38,7 @@
#include "mrcp_generic_header.h"
#include "mrcp_recog_header.h"
#include "mrcp_recog_resource.h"
#include "apt_nlsml_doc.h"
#include "apt_log.h"
typedef struct recog_app_channel_t recog_app_channel_t;
@@ -71,7 +72,9 @@ static const mrcp_app_message_dispatcher_t recog_application_dispatcher = {
recog_application_on_session_terminate,
recog_application_on_channel_add,
recog_application_on_channel_remove,
recog_application_on_message_receive
recog_application_on_message_receive,
NULL /* recog_application_on_terminate_event */,
NULL /* recog_application_on_resource_discover */
};
/** Declaration of recognizer audio stream methods */
@@ -87,6 +90,7 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = {
recog_app_stream_read,
NULL,
NULL,
NULL,
NULL
};
@@ -240,19 +244,26 @@ static apt_bool_t recog_application_on_channel_remove(mrcp_application_t *applic
/** Handle the DEFINE-GRAMMAR responses */
static apt_bool_t recog_application_on_define_grammar(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel)
{
recog_app_channel_t *recog_channel = mrcp_application_channel_object_get(channel);
mrcp_message_t *mrcp_message;
recog_app_channel_t *recog_channel = mrcp_application_channel_object_get(channel);
const apt_dir_layout_t *dir_layout = mrcp_application_dir_layout_get(application);
apr_pool_t *pool = mrcp_application_session_pool_get(session);
const mpf_codec_descriptor_t *descriptor = mrcp_application_source_descriptor_get(channel);
if(!descriptor) {
/* terminate the demo */
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Source Descriptor");
return mrcp_application_session_terminate(session);
}
/* create and send RECOGNIZE request */
mrcp_message = demo_recognize_message_create(session,channel,dir_layout);
if(mrcp_message) {
mrcp_application_message_send(session,channel,mrcp_message);
}
if(recog_channel) {
const mpf_codec_descriptor_t *descriptor = mrcp_application_source_descriptor_get(channel);
char *file_name = apr_psprintf(pool,"one-%dkHz.pcm",
descriptor ? descriptor->sampling_rate/1000 : 8);
apr_pool_t *pool = mrcp_application_session_pool_get(session);
char *file_name = apr_psprintf(pool,"one-%dkHz.pcm",descriptor->sampling_rate/1000);
char *file_path = apt_datadir_filepath_get(dir_layout,file_name,pool);
if(file_path) {
recog_channel->audio_in = fopen(file_path,"rb");
@@ -303,7 +314,11 @@ static apt_bool_t recog_application_on_message_receive(mrcp_application_t *appli
}
else if(message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
if(message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
demo_nlsml_result_parse(message);
nlsml_result_t *result = nlsml_result_parse(message->body.buf, message->body.length, message->pool);
if(result) {
nlsml_result_trace(result, message->pool);
}
if(recog_channel) {
recog_channel->streaming = FALSE;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: demo_synth_application.c 1474 2010-02-07 20:51:47Z achaloyan $
* $Id: demo_synth_application.c 2193 2014-10-08 03:44:33Z achaloyan@gmail.com $
*/
/*
@@ -37,6 +37,7 @@
#include "mrcp_generic_header.h"
#include "mrcp_synth_header.h"
#include "mrcp_synth_resource.h"
#include "apt_log.h"
typedef struct synth_app_channel_t synth_app_channel_t;
@@ -64,7 +65,9 @@ static const mrcp_app_message_dispatcher_t synth_application_dispatcher = {
synth_application_on_session_terminate,
synth_application_on_channel_add,
synth_application_on_channel_remove,
synth_application_on_message_receive
synth_application_on_message_receive,
NULL /* synth_application_on_terminate_event */,
NULL /* synth_application_on_resource_discover */
};
/** Declaration of synthesizer audio stream methods */
@@ -80,7 +83,8 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = {
NULL,
synth_app_stream_open,
synth_app_stream_close,
synth_app_stream_write
synth_app_stream_write,
NULL
};
@@ -196,26 +200,36 @@ static apt_bool_t synth_application_on_session_terminate(mrcp_application_t *app
/** Handle the responses sent to channel add requests */
static apt_bool_t synth_application_on_channel_add(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status)
{
synth_app_channel_t *synth_channel = mrcp_application_channel_object_get(channel);
apr_pool_t *pool = mrcp_application_session_pool_get(session);
if(status == MRCP_SIG_STATUS_CODE_SUCCESS) {
mrcp_message_t *mrcp_message;
synth_app_channel_t *synth_channel = mrcp_application_channel_object_get(channel);
apr_pool_t *pool = mrcp_application_session_pool_get(session);
const apt_dir_layout_t *dir_layout = mrcp_application_dir_layout_get(application);
const mpf_codec_descriptor_t *descriptor = mrcp_application_sink_descriptor_get(channel);
if(!descriptor) {
/* terminate the demo */
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Sink Descriptor");
return mrcp_application_session_terminate(session);
}
/* create and send SPEAK request */
mrcp_message = demo_speak_message_create(session,channel,dir_layout);
if(mrcp_message) {
mrcp_application_message_send(session,channel,mrcp_message);
}
if(synth_channel && session) {
if(synth_channel) {
const apt_str_t *id = mrcp_application_session_id_get(session);
const mpf_codec_descriptor_t *descriptor = mrcp_application_sink_descriptor_get(channel);
char *file_name = apr_psprintf(pool,"synth-%dkHz-%s.pcm",
descriptor ? descriptor->sampling_rate/1000 : 8,
id->buf);
char *file_path = apt_datadir_filepath_get(dir_layout,file_name,pool);
descriptor->sampling_rate/1000,
id->buf);
char *file_path = apt_vardir_filepath_get(dir_layout,file_name,pool);
if(file_path) {
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Speech Output File [%s] for Writing",file_path);
synth_channel->audio_out = fopen(file_path,"wb");
if(!synth_channel->audio_out) {
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Utterance Output File [%s] for Writing",file_path);
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: demo_util.c 1474 2010-02-07 20:51:47Z achaloyan $
* $Id: demo_util.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
*/
#include "demo_util.h"
@@ -26,8 +26,6 @@
/* recognizer includes */
#include "mrcp_recog_header.h"
#include "mrcp_recog_resource.h"
/* NLSML doc include */
#include "apt_nlsml_doc.h"
/* logger include */
#include "apt_log.h"
@@ -141,38 +139,6 @@ mrcp_message_t* demo_recognize_message_create(mrcp_session_t *session, mrcp_chan
return mrcp_message;
}
/** Parse NLSML result */
apt_bool_t demo_nlsml_result_parse(mrcp_message_t *message)
{
apr_xml_elem *interpret;
apr_xml_elem *instance;
apr_xml_elem *input;
apr_xml_doc *doc = nlsml_doc_load(&message->body,message->pool);
if(!doc) {
return FALSE;
}
/* walk through interpreted results */
interpret = nlsml_first_interpret_get(doc);
for(; interpret; interpret = nlsml_next_interpret_get(interpret)) {
/* get instance and input */
nlsml_interpret_results_get(interpret,&instance,&input);
if(instance) {
/* process instance */
if(instance->first_cdata.first) {
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpreted Instance [%s]",instance->first_cdata.first->text);
}
}
if(input) {
/* process input */
if(input->first_cdata.first) {
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpreted Input [%s]",input->first_cdata.first->text);
}
}
}
return TRUE;
}
/** Create demo RTP termination descriptor */
mpf_rtp_termination_descriptor_t* demo_rtp_descriptor_create(apr_pool_t *pool)
{
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 Arsen Chaloyan
* Copyright 2008-2014 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,19 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: main.c 1785 2010-09-22 06:14:29Z achaloyan $
* $Id: main.c 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $
*/
#include <stdio.h>
#include <stdlib.h>
#include <apr_getopt.h>
#include <apr_file_info.h>
#include "demo_framework.h"
#include "apt_pool.h"
#include "apt_log.h"
#include "uni_version.h"
typedef struct {
const char *root_dir_path;
const char *dir_layout_conf;
const char *log_priority;
const char *log_output;
} client_options_t;
@@ -79,7 +80,7 @@ static apt_bool_t demo_framework_cmdline_run(demo_framework_t *framework)
{
apt_bool_t running = TRUE;
char cmdline[1024];
int i;
apr_size_t i;
do {
printf(">");
memset(&cmdline, 0, sizeof(cmdline));
@@ -98,9 +99,13 @@ static apt_bool_t demo_framework_cmdline_run(demo_framework_t *framework)
return TRUE;
}
static void usage()
static void usage(void)
{
printf(
"\n"
" * "UNI_COPYRIGHT"\n"
" *\n"
UNI_LICENSE"\n"
"\n"
"Usage:\n"
"\n"
@@ -108,7 +113,10 @@ static void usage()
"\n"
" Available options:\n"
"\n"
" -r [--root-dir] path : Set the project root directory path.\n"
" -r [--root-dir] path : Set the path to the project root directory.\n"
"\n"
" -c [--dir-layout] path : Set the path to the dir layout config file.\n"
" (takes the precedence over --root-dir option)\n"
"\n"
" -l [--log-prio] priority : Set the log priority.\n"
" (0-emergency, ..., 7-debug)\n"
@@ -116,6 +124,8 @@ static void usage()
" -o [--log-output] mode : Set the log output mode.\n"
" (0-none, 1-console only, 2-file only, 3-both)\n"
"\n"
" -v [--version] : Show the version.\n"
"\n"
" -h [--help] : Show the help.\n"
"\n");
}
@@ -129,11 +139,13 @@ static apt_bool_t demo_framework_options_load(client_options_t *options, int arg
const apr_getopt_option_t opt_option[] = {
/* long-option, short-option, has-arg flag, description */
{ "root-dir", 'r', TRUE, "path to root dir" }, /* -r arg or --root-dir arg */
{ "log-prio", 'l', TRUE, "log priority" }, /* -l arg or --log-prio arg */
{ "log-output", 'o', TRUE, "log output mode" }, /* -o arg or --log-output arg */
{ "help", 'h', FALSE, "show help" }, /* -h or --help */
{ NULL, 0, 0, NULL }, /* end */
{ "root-dir", 'r', TRUE, "path to root dir" }, /* -r arg or --root-dir arg */
{ "dir-layout", 'c', TRUE, "path to dir layout conf" }, /* -c arg or --dir-layout arg */
{ "log-prio", 'l', TRUE, "log priority" }, /* -l arg or --log-prio arg */
{ "log-output", 'o', TRUE, "log output mode" }, /* -o arg or --log-output arg */
{ "version", 'v', FALSE, "show version" }, /* -v or --version */
{ "help", 'h', FALSE, "show help" }, /* -h or --help */
{ NULL, 0, 0, NULL }, /* end */
};
rv = apr_getopt_init(&opt, pool , argc, argv);
@@ -141,17 +153,29 @@ static apt_bool_t demo_framework_options_load(client_options_t *options, int arg
return FALSE;
}
/* reset the options */
options->root_dir_path = NULL;
options->dir_layout_conf = NULL;
options->log_priority = NULL;
options->log_output = NULL;
while((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
switch(optch) {
case 'r':
options->root_dir_path = optarg;
break;
case 'c':
options->dir_layout_conf = optarg;
break;
case 'l':
options->log_priority = optarg;
break;
case 'o':
options->log_output = optarg;
break;
case 'v':
printf(UNI_VERSION_STRING);
return FALSE;
case 'h':
usage();
return FALSE;
@@ -168,11 +192,11 @@ static apt_bool_t demo_framework_options_load(client_options_t *options, int arg
int main(int argc, const char * const *argv)
{
apr_pool_t *pool = NULL;
apr_pool_t *pool;
client_options_t options;
apt_dir_layout_t *dir_layout;
const char *log_conf_path;
demo_framework_t *framework;
apt_dir_layout_t *dir_layout = NULL;
/* APR global initialization */
if(apr_initialize() != APR_SUCCESS) {
@@ -187,11 +211,6 @@ int main(int argc, const char * const *argv)
return 0;
}
/* set the default options */
options.root_dir_path = "../";
options.log_priority = NULL;
options.log_output = NULL;
/* load options */
if(demo_framework_options_load(&options,argc,argv,pool) != TRUE) {
apr_pool_destroy(pool);
@@ -199,8 +218,23 @@ int main(int argc, const char * const *argv)
return 0;
}
/* create the structure of default directories layout */
dir_layout = apt_default_dir_layout_create(options.root_dir_path,pool);
if(options.dir_layout_conf) {
/* create and load directories layout from the configuration file */
dir_layout = apt_dir_layout_create(pool);
if(dir_layout)
apt_dir_layout_load(dir_layout,options.dir_layout_conf,pool);
}
else {
/* create default directories layout */
dir_layout = apt_default_dir_layout_create(options.root_dir_path,pool);
}
if(!dir_layout) {
printf("Failed to Create Directories Layout\n");
apr_pool_destroy(pool);
apr_terminate();
return 0;
}
/* get path to logger configuration file */
log_conf_path = apt_confdir_filepath_get(dir_layout,"logger.xml",pool);
@@ -218,7 +252,8 @@ int main(int argc, const char * const *argv)
if(apt_log_output_mode_check(APT_LOG_OUTPUT_FILE) == TRUE) {
/* open the log file */
apt_log_file_open(dir_layout->log_dir_path,"unimrcpclient",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,FALSE,pool);
const char *log_dir_path = apt_dir_layout_path_get(dir_layout,APT_LAYOUT_LOG_DIR);
apt_log_file_open(log_dir_path,"unimrcpclient",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,FALSE,pool);
}
/* create demo framework */