mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-15 05:48:33 +00:00
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:
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: dtmfscenario.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: dtmfscenario.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -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: dtmfsession.cpp 1780 2010-09-01 05:59:32Z achaloyan $
|
||||
* $Id: dtmfsession.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "dtmfsession.h"
|
||||
@@ -117,6 +117,7 @@ RecogChannel* DtmfSession::CreateRecogChannel()
|
||||
ReadStream,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -267,37 +268,12 @@ mrcp_message_t* DtmfSession::CreateRecognizeRequest(mrcp_channel_t* pMrcpChannel
|
||||
return pMrcpMessage;
|
||||
}
|
||||
|
||||
bool DtmfSession::ParseNLSMLResult(mrcp_message_t* pMrcpMessage) const
|
||||
bool DtmfSession::ParseNLSMLResult(mrcp_message_t* pMrcpMessage)
|
||||
{
|
||||
apr_xml_elem* pInterpret;
|
||||
apr_xml_elem* pInstance;
|
||||
apr_xml_elem* pInput;
|
||||
apr_xml_doc* pDoc = nlsml_doc_load(&pMrcpMessage->body,pMrcpMessage->pool);
|
||||
if(!pDoc)
|
||||
nlsml_result_t *pResult = nlsml_result_parse(pMrcpMessage->body.buf, pMrcpMessage->body.length, pMrcpMessage->pool);
|
||||
if(!pResult)
|
||||
return false;
|
||||
|
||||
/* walk through interpreted results */
|
||||
pInterpret = nlsml_first_interpret_get(pDoc);
|
||||
for(; pInterpret; pInterpret = nlsml_next_interpret_get(pInterpret))
|
||||
{
|
||||
/* get instance and input */
|
||||
nlsml_interpret_results_get(pInterpret,&pInstance,&pInput);
|
||||
if(pInstance)
|
||||
{
|
||||
/* process instance */
|
||||
if(pInstance->first_cdata.first)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpreted Instance [%s]",pInstance->first_cdata.first->text);
|
||||
}
|
||||
}
|
||||
if(pInput)
|
||||
{
|
||||
/* process input */
|
||||
if(pInput->first_cdata.first)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpreted Input [%s]",pInput->first_cdata.first->text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nlsml_result_trace(pResult, pMrcpMessage->pool);
|
||||
return true;
|
||||
}
|
||||
@@ -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: main.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: main.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "umcconsole.h"
|
||||
|
||||
@@ -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: recogscenario.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: recogscenario.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -30,6 +30,7 @@ RecogScenario::RecogScenario() :
|
||||
m_Recognize(true),
|
||||
m_ContentType("application/srgs+xml"),
|
||||
m_Content(NULL),
|
||||
m_ContentLength(0),
|
||||
m_AudioSource(NULL)
|
||||
{
|
||||
}
|
||||
@@ -102,7 +103,7 @@ bool RecogScenario::LoadDefineGrammar(const apr_xml_elem* pElem, apr_pool_t* poo
|
||||
}
|
||||
else if(strcasecmp(pAttr->name,"content-location") == 0)
|
||||
{
|
||||
m_Content = LoadFileContent(pAttr->value,pool);
|
||||
m_Content = LoadFileContent(pAttr->value,m_ContentLength,pool);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -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: recogsession.cpp 1587 2010-03-12 19:40:02Z achaloyan $
|
||||
* $Id: recogsession.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "recogsession.h"
|
||||
@@ -184,6 +184,7 @@ RecogChannel* RecogSession::CreateRecogChannel()
|
||||
ReadStream,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -309,6 +310,13 @@ bool RecogSession::OnDefineGrammar(mrcp_channel_t* pMrcpChannel)
|
||||
|
||||
bool RecogSession::StartRecognition(mrcp_channel_t* pMrcpChannel)
|
||||
{
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
|
||||
if(!pDescriptor)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Source Descriptor");
|
||||
return Terminate();
|
||||
}
|
||||
|
||||
RecogChannel* pRecogChannel = (RecogChannel*) mrcp_application_channel_object_get(pMrcpChannel);
|
||||
/* create and send RECOGNIZE request */
|
||||
mrcp_message_t* pMrcpMessage = CreateRecognizeRequest(pMrcpChannel);
|
||||
@@ -317,7 +325,6 @@ bool RecogSession::StartRecognition(mrcp_channel_t* pMrcpChannel)
|
||||
SendMrcpRequest(pRecogChannel->m_pMrcpChannel,pMrcpMessage);
|
||||
}
|
||||
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
|
||||
pRecogChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
|
||||
if(!pRecogChannel->m_pAudioIn)
|
||||
{
|
||||
@@ -352,7 +359,7 @@ mrcp_message_t* RecogSession::CreateDefineGrammarRequest(mrcp_channel_t* pMrcpCh
|
||||
|
||||
/* set message body */
|
||||
if(pScenario->GetContent())
|
||||
apt_string_assign(&pMrcpMessage->body,pScenario->GetContent(),pMrcpMessage->pool);
|
||||
apt_string_assign_n(&pMrcpMessage->body,pScenario->GetContent(),pScenario->GetContentLength(),pMrcpMessage->pool);
|
||||
return pMrcpMessage;
|
||||
}
|
||||
|
||||
@@ -409,42 +416,19 @@ mrcp_message_t* RecogSession::CreateRecognizeRequest(mrcp_channel_t* pMrcpChanne
|
||||
mrcp_resource_header_property_add(pMrcpMessage,RECOGNIZER_HEADER_START_INPUT_TIMERS);
|
||||
pRecogHeader->confidence_threshold = 0.87f;
|
||||
mrcp_resource_header_property_add(pMrcpMessage,RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD);
|
||||
pRecogHeader->save_waveform = TRUE;
|
||||
mrcp_resource_header_property_add(pMrcpMessage,RECOGNIZER_HEADER_SAVE_WAVEFORM);
|
||||
}
|
||||
return pMrcpMessage;
|
||||
}
|
||||
|
||||
bool RecogSession::ParseNLSMLResult(mrcp_message_t* pMrcpMessage) const
|
||||
bool RecogSession::ParseNLSMLResult(mrcp_message_t* pMrcpMessage)
|
||||
{
|
||||
apr_xml_elem* pInterpret;
|
||||
apr_xml_elem* pInstance;
|
||||
apr_xml_elem* pInput;
|
||||
apr_xml_doc* pDoc = nlsml_doc_load(&pMrcpMessage->body,pMrcpMessage->pool);
|
||||
if(!pDoc)
|
||||
nlsml_result_t *pResult = nlsml_result_parse(pMrcpMessage->body.buf, pMrcpMessage->body.length, pMrcpMessage->pool);
|
||||
if(!pResult)
|
||||
return false;
|
||||
|
||||
/* walk through interpreted results */
|
||||
pInterpret = nlsml_first_interpret_get(pDoc);
|
||||
for(; pInterpret; pInterpret = nlsml_next_interpret_get(pInterpret))
|
||||
{
|
||||
/* get instance and input */
|
||||
nlsml_interpret_results_get(pInterpret,&pInstance,&pInput);
|
||||
if(pInstance)
|
||||
{
|
||||
/* process instance */
|
||||
if(pInstance->first_cdata.first)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpreted Instance [%s]",pInstance->first_cdata.first->text);
|
||||
}
|
||||
}
|
||||
if(pInput)
|
||||
{
|
||||
/* process input */
|
||||
if(pInput->first_cdata.first)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpreted Input [%s]",pInput->first_cdata.first->text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nlsml_result_trace(pResult, pMrcpMessage->pool);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -453,8 +437,7 @@ FILE* RecogSession::GetAudioIn(const mpf_codec_descriptor_t* pDescriptor, apr_po
|
||||
const char* pFileName = GetScenario()->GetAudioSource();
|
||||
if(!pFileName)
|
||||
{
|
||||
pFileName = apr_psprintf(pool,"one-%dkHz.pcm",
|
||||
pDescriptor ? pDescriptor->sampling_rate/1000 : 8);
|
||||
pFileName = apr_psprintf(pool,"one-%dkHz.pcm",pDescriptor->sampling_rate/1000);
|
||||
}
|
||||
apt_dir_layout_t* pDirLayout = GetScenario()->GetDirLayout();
|
||||
const char* pFilePath = apt_datadir_filepath_get(pDirLayout,pFileName,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,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: recorderscenario.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: recorderscenario.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -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: recordersession.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: recordersession.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "recordersession.h"
|
||||
@@ -129,6 +129,7 @@ RecorderChannel* RecorderSession::CreateRecorderChannel()
|
||||
ReadStream,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -217,6 +218,13 @@ bool RecorderSession::OnMessageReceive(mrcp_channel_t* pMrcpChannel, mrcp_messag
|
||||
|
||||
bool RecorderSession::StartRecorder(mrcp_channel_t* pMrcpChannel)
|
||||
{
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
|
||||
if(!pDescriptor)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Source Descriptor");
|
||||
return Terminate();
|
||||
}
|
||||
|
||||
RecorderChannel* pRecorderChannel = (RecorderChannel*) mrcp_application_channel_object_get(pMrcpChannel);
|
||||
/* create and send RECORD request */
|
||||
mrcp_message_t* pMrcpMessage = CreateRecordRequest(pMrcpChannel);
|
||||
@@ -225,7 +233,6 @@ bool RecorderSession::StartRecorder(mrcp_channel_t* pMrcpChannel)
|
||||
SendMrcpRequest(pRecorderChannel->m_pMrcpChannel,pMrcpMessage);
|
||||
}
|
||||
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
|
||||
pRecorderChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
|
||||
return true;
|
||||
}
|
||||
@@ -260,8 +267,7 @@ FILE* RecorderSession::GetAudioIn(const mpf_codec_descriptor_t* pDescriptor, apr
|
||||
const char* pFileName = GetScenario()->GetAudioSource();
|
||||
if(!pFileName)
|
||||
{
|
||||
pFileName = apr_psprintf(pool,"demo-%dkHz.pcm",
|
||||
pDescriptor ? pDescriptor->sampling_rate/1000 : 8);
|
||||
pFileName = apr_psprintf(pool,"demo-%dkHz.pcm",pDescriptor->sampling_rate/1000);
|
||||
}
|
||||
apt_dir_layout_t* pDirLayout = GetScenario()->GetDirLayout();
|
||||
const char* pFilePath = apt_datadir_filepath_get(pDirLayout,pFileName,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,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: setparamscenario.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: setparamscenario.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "setparamscenario.h"
|
||||
|
||||
@@ -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: setparamsession.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: setparamsession.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "setparamsession.h"
|
||||
@@ -97,6 +97,7 @@ RecogChannel* SetParamSession::CreateRecogChannel()
|
||||
ReadStream,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -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: synthscenario.cpp 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
* $Id: synthscenario.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -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: synthsession.cpp 1586 2010-03-12 19:39:02Z achaloyan $
|
||||
* $Id: synthsession.cpp 2193 2014-10-08 03:44:33Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "synthsession.h"
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "mrcp_generic_header.h"
|
||||
#include "mrcp_synth_header.h"
|
||||
#include "mrcp_synth_resource.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
struct SynthChannel
|
||||
{
|
||||
@@ -145,7 +146,8 @@ SynthChannel* SynthSession::CreateSynthChannel()
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
WriteStream
|
||||
WriteStream,
|
||||
NULL
|
||||
};
|
||||
|
||||
pTermination = CreateAudioTermination(
|
||||
@@ -173,6 +175,13 @@ bool SynthSession::OnChannelAdd(mrcp_channel_t* pMrcpChannel, mrcp_sig_status_co
|
||||
if(!UmcSession::OnChannelAdd(pMrcpChannel,status))
|
||||
return false;
|
||||
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_sink_descriptor_get(pMrcpChannel);
|
||||
if(!pDescriptor)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Sink Descriptor");
|
||||
return Terminate();
|
||||
}
|
||||
|
||||
SynthChannel* pSynthChannel = (SynthChannel*) mrcp_application_channel_object_get(pMrcpChannel);
|
||||
if(status != MRCP_SIG_STATUS_CODE_SUCCESS)
|
||||
{
|
||||
@@ -187,7 +196,6 @@ bool SynthSession::OnChannelAdd(mrcp_channel_t* pMrcpChannel, mrcp_sig_status_co
|
||||
SendMrcpRequest(pSynthChannel->m_pMrcpChannel,pMrcpMessage);
|
||||
}
|
||||
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_sink_descriptor_get(pMrcpChannel);
|
||||
pSynthChannel->m_pAudioOut = GetAudioOut(pDescriptor,GetSessionPool());
|
||||
return true;
|
||||
}
|
||||
@@ -273,12 +281,19 @@ mrcp_message_t* SynthSession::CreateSpeakRequest(mrcp_channel_t* pMrcpChannel)
|
||||
|
||||
FILE* SynthSession::GetAudioOut(const mpf_codec_descriptor_t* pDescriptor, apr_pool_t* pool) const
|
||||
{
|
||||
char* pFileName = apr_psprintf(pool,"synth-%dkHz-%s.pcm",
|
||||
pDescriptor ? pDescriptor->sampling_rate/1000 : 8, GetMrcpSessionId());
|
||||
FILE* file;
|
||||
char* pFileName = apr_psprintf(pool,"synth-%dkHz-%s.pcm",pDescriptor->sampling_rate/1000, GetMrcpSessionId());
|
||||
apt_dir_layout_t* pDirLayout = GetScenario()->GetDirLayout();
|
||||
char* pFilePath = apt_datadir_filepath_get(pDirLayout,pFileName,pool);
|
||||
if(!pFilePath)
|
||||
char* pFilePath = apt_vardir_filepath_get(pDirLayout,pFileName,pool);
|
||||
if(!pFilePath)
|
||||
return NULL;
|
||||
|
||||
return fopen(pFilePath,"wb");
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Speech Output File [%s] for Writing",pFilePath);
|
||||
file = fopen(pFilePath,"wb");
|
||||
if(!file)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Speech Output File [%s] for Writing",pFilePath);
|
||||
return NULL;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
@@ -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: umcconsole.cpp 1785 2010-09-22 06:14:29Z achaloyan $
|
||||
* $Id: umcconsole.cpp 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "umcconsole.h"
|
||||
#include "umcframework.h"
|
||||
#include "apt_pool.h"
|
||||
#include "uni_version.h"
|
||||
|
||||
|
||||
UmcConsole::UmcConsole() :
|
||||
@@ -64,8 +65,26 @@ bool UmcConsole::Run(int argc, const char * const *argv)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create the structure of default directories layout */
|
||||
pDirLayout = apt_default_dir_layout_create(m_Options.m_RootDirPath,pool);
|
||||
if(m_Options.m_DirLayoutConf)
|
||||
{
|
||||
/* create and load directories layout from the configuration file */
|
||||
pDirLayout = apt_dir_layout_create(pool);
|
||||
if(pDirLayout)
|
||||
apt_dir_layout_load(pDirLayout,m_Options.m_DirLayoutConf,pool);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* create default directories layout */
|
||||
pDirLayout = apt_default_dir_layout_create(m_Options.m_RootDirPath,pool);
|
||||
}
|
||||
|
||||
if(!pDirLayout)
|
||||
{
|
||||
printf("Failed to Create Directories Layout\n");
|
||||
apr_pool_destroy(pool);
|
||||
apr_terminate();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get path to logger configuration file */
|
||||
logConfPath = apt_confdir_filepath_get(pDirLayout,"logger.xml",pool);
|
||||
@@ -86,7 +105,8 @@ bool UmcConsole::Run(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(pDirLayout->log_dir_path,"unimrcpclient",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,FALSE,pool);
|
||||
const char *logDirPath = apt_dir_layout_path_get(pDirLayout,APT_LAYOUT_LOG_DIR);
|
||||
apt_log_file_open(logDirPath,"unimrcpclient",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,FALSE,pool);
|
||||
}
|
||||
|
||||
/* create demo framework */
|
||||
@@ -199,7 +219,7 @@ bool UmcConsole::RunCmdLine()
|
||||
{
|
||||
apt_bool_t running = true;
|
||||
char cmdline[1024];
|
||||
int i;
|
||||
apr_size_t i;
|
||||
do
|
||||
{
|
||||
printf(">");
|
||||
@@ -222,9 +242,13 @@ bool UmcConsole::RunCmdLine()
|
||||
return true;
|
||||
}
|
||||
|
||||
void UmcConsole::Usage() const
|
||||
void UmcConsole::Usage()
|
||||
{
|
||||
printf(
|
||||
"\n"
|
||||
" * "UNI_COPYRIGHT"\n"
|
||||
" *\n"
|
||||
UNI_LICENSE"\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
@@ -232,7 +256,10 @@ void UmcConsole::Usage() const
|
||||
"\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"
|
||||
@@ -240,6 +267,8 @@ void UmcConsole::Usage() const
|
||||
" -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");
|
||||
}
|
||||
@@ -254,18 +283,15 @@ bool UmcConsole::LoadOptions(int argc, const char * const *argv, apr_pool_t *poo
|
||||
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 */
|
||||
};
|
||||
|
||||
/* set the default options */
|
||||
m_Options.m_RootDirPath = "../";
|
||||
m_Options.m_LogPriority = NULL;
|
||||
m_Options.m_LogOutput = NULL;
|
||||
|
||||
rv = apr_getopt_init(&opt, pool , argc, argv);
|
||||
if(rv != APR_SUCCESS)
|
||||
return false;
|
||||
@@ -277,6 +303,9 @@ bool UmcConsole::LoadOptions(int argc, const char * const *argv, apr_pool_t *poo
|
||||
case 'r':
|
||||
m_Options.m_RootDirPath = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
m_Options.m_DirLayoutConf = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
if(optarg)
|
||||
m_Options.m_LogPriority = optarg;
|
||||
@@ -285,6 +314,9 @@ bool UmcConsole::LoadOptions(int argc, const char * const *argv, apr_pool_t *poo
|
||||
if(optarg)
|
||||
m_Options.m_LogOutput = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
printf(UNI_VERSION_STRING);
|
||||
return FALSE;
|
||||
case 'h':
|
||||
Usage();
|
||||
return 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: umcframework.cpp 1767 2010-08-23 19:10:22Z achaloyan $
|
||||
* $Id: umcframework.cpp 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "umcframework.h"
|
||||
@@ -193,7 +193,12 @@ apr_xml_doc* UmcFramework::LoadDocument()
|
||||
apr_status_t rv;
|
||||
const char* pFilePath;
|
||||
|
||||
pFilePath = apr_psprintf(m_pPool,"%s/%s",m_pDirLayout->conf_dir_path,"umcscenarios.xml");
|
||||
pFilePath = apt_dir_layout_path_compose(m_pDirLayout,APT_LAYOUT_CONF_DIR,"umcscenarios.xml",m_pPool);
|
||||
if(!pFilePath)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Compose Config File Path");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Open Config File [%s]",pFilePath);
|
||||
rv = apr_file_open(&pFD,pFilePath,APR_READ|APR_BINARY,0,m_pPool);
|
||||
|
||||
@@ -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: umcscenario.cpp 1571 2010-03-07 20:33:39Z achaloyan $
|
||||
* $Id: umcscenario.cpp 2232 2014-11-12 01:33:37Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -40,7 +40,8 @@ bool UmcScenario::Load(const apr_xml_elem* pElem, apr_pool_t* pool)
|
||||
/* Load Child Elements */
|
||||
for(pChildElem = pElem->first_child; pChildElem; pChildElem = pChildElem->next)
|
||||
{
|
||||
LoadElement(pChildElem,pool);
|
||||
if(!LoadElement(pChildElem,pool))
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Load Child Element %s",pChildElem->name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -95,7 +96,7 @@ bool UmcScenario::LoadCapabilities(const apr_xml_elem* pElem, apr_pool_t* pool)
|
||||
{
|
||||
const apr_xml_elem* pChildElem;
|
||||
/* Load Child Elements */
|
||||
m_pCapabilities = (mpf_codec_capabilities_t*) apr_palloc(pool,sizeof(mpf_codec_capabilities_t*));
|
||||
m_pCapabilities = (mpf_codec_capabilities_t*) apr_palloc(pool,sizeof(mpf_codec_capabilities_t));
|
||||
mpf_codec_capabilities_init(m_pCapabilities,1,pool);
|
||||
for(pChildElem = pElem->first_child; pChildElem; pChildElem = pChildElem->next)
|
||||
{
|
||||
@@ -126,7 +127,7 @@ bool UmcScenario::LoadCapabilities(const apr_xml_elem* pElem, apr_pool_t* pool)
|
||||
return true;
|
||||
}
|
||||
|
||||
int UmcScenario::ParseRates(const char* pStr, apr_pool_t* pool) const
|
||||
int UmcScenario::ParseRates(const char* pStr, apr_pool_t* pool)
|
||||
{
|
||||
int rates = 0;
|
||||
if(pStr)
|
||||
@@ -181,7 +182,7 @@ bool UmcScenario::InitCapabilities(mpf_stream_capabilities_t* pCapabilities) con
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UmcScenario::IsElementEnabled(const apr_xml_elem* pElem) const
|
||||
bool UmcScenario::IsElementEnabled(const apr_xml_elem* pElem)
|
||||
{
|
||||
const apr_xml_attr* pAttr;
|
||||
for(pAttr = pElem->attr; pAttr; pAttr = pAttr->next)
|
||||
@@ -194,7 +195,7 @@ bool UmcScenario::IsElementEnabled(const apr_xml_elem* pElem) const
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* UmcScenario::LoadFileContent(const char* pFileName, apr_pool_t* pool) const
|
||||
const char* UmcScenario::LoadFileContent(const char* pFileName, apr_size_t& size, apr_pool_t* pool) const
|
||||
{
|
||||
if(!m_pDirLayout || !pFileName)
|
||||
return NULL;
|
||||
@@ -218,7 +219,7 @@ const char* UmcScenario::LoadFileContent(const char* pFileName, apr_pool_t* pool
|
||||
return NULL;
|
||||
}
|
||||
|
||||
apr_size_t size = (apr_size_t)finfo.size;
|
||||
size = (apr_size_t)finfo.size;
|
||||
char* pContent = (char*) apr_palloc(pool,size+1);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Load File Content size [%"APR_SIZE_T_FMT" bytes] %s",size,pFilePath);
|
||||
if(apr_file_read(pFile,pContent,&size) != APR_SUCCESS)
|
||||
|
||||
@@ -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: umcsession.cpp 1695 2010-05-19 18:56:15Z achaloyan $
|
||||
* $Id: umcsession.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "umcsession.h"
|
||||
|
||||
@@ -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: verifierscenario.cpp 1775 2010-08-26 18:23:38Z achaloyan $
|
||||
* $Id: verifierscenario.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -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: verifiersession.cpp 1778 2010-08-27 17:34:52Z achaloyan $
|
||||
* $Id: verifiersession.cpp 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
|
||||
*/
|
||||
|
||||
#include "verifiersession.h"
|
||||
@@ -164,6 +164,7 @@ VerifierChannel* VerifierSession::CreateVerifierChannel()
|
||||
ReadStream,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -266,7 +267,7 @@ bool VerifierSession::OnMessageReceive(mrcp_channel_t* pMrcpChannel, mrcp_messag
|
||||
|
||||
/* create and send END-SESSION request */
|
||||
mrcp_message_t* pMrcpMessage = CreateEndSessionRequest(pMrcpChannel);
|
||||
if(pMrcpMessage)
|
||||
if(pVerifierChannel && pMrcpMessage)
|
||||
{
|
||||
SendMrcpRequest(pVerifierChannel->m_pMrcpChannel,pMrcpMessage);
|
||||
}
|
||||
@@ -281,6 +282,13 @@ bool VerifierSession::OnMessageReceive(mrcp_channel_t* pMrcpChannel, mrcp_messag
|
||||
|
||||
bool VerifierSession::StartVerification(mrcp_channel_t* pMrcpChannel)
|
||||
{
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
|
||||
if(!pDescriptor)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Source Descriptor");
|
||||
return Terminate();
|
||||
}
|
||||
|
||||
VerifierChannel* pVerifierChannel = (VerifierChannel*) mrcp_application_channel_object_get(pMrcpChannel);
|
||||
/* create and send Verification request */
|
||||
mrcp_message_t* pMrcpMessage = CreateStartSessionRequest(pMrcpChannel);
|
||||
@@ -289,7 +297,6 @@ bool VerifierSession::StartVerification(mrcp_channel_t* pMrcpChannel)
|
||||
SendMrcpRequest(pVerifierChannel->m_pMrcpChannel,pMrcpMessage);
|
||||
}
|
||||
|
||||
const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
|
||||
pVerifierChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
|
||||
if(!pVerifierChannel->m_pAudioIn)
|
||||
{
|
||||
@@ -371,7 +378,7 @@ FILE* VerifierSession::GetAudioIn(const mpf_codec_descriptor_t* pDescriptor, apr
|
||||
|
||||
const char* pFileName = apr_psprintf(pool,"%s-%dkHz.pcm",
|
||||
pVoiceprintIdentifier,
|
||||
pDescriptor ? pDescriptor->sampling_rate/1000 : 8);
|
||||
pDescriptor->sampling_rate/1000);
|
||||
apt_dir_layout_t* pDirLayout = pScenario->GetDirLayout();
|
||||
const char* pFilePath = apt_datadir_filepath_get(pDirLayout,pFileName,pool);
|
||||
if(!pFilePath)
|
||||
|
||||
Reference in new issue
Block a user