From f87c335e8a49da7b0a2b6f19b45f285f6355e2e0 Mon Sep 17 00:00:00 2001 From: Italo Rossi Date: Mon, 3 Nov 2014 12:02:03 -0300 Subject: [PATCH 01/10] Only waiting for agent channel to hangup. If the member do an attended transfer this loop stops and the agent is set to Available state again, when in fact he still busy with other channel. This was happening, for example, when a member calls support queue, then the support operator do an attended transfer to sales queue, while the sales operator is talking the member that was transferred, the sales queue will send calls to the operator, which is not expected. --- src/mod/applications/mod_callcenter/mod_callcenter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 5c2c6ebee2..8d4c0caf06 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -1730,8 +1730,8 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa /* This is used for the waiting caller to quit waiting for a agent */ switch_channel_set_variable(member_channel, "cc_agent_found", "true"); - /* Wait until the member hangup or the agent hangup. This will quit also if the agent transfer the call */ - while(switch_channel_up(member_channel) && switch_channel_up(agent_channel) && globals.running) { + /* Wait until the agent hangup. This will quit also if the agent transfer the call */ + while(switch_channel_up(agent_channel) && globals.running) { switch_yield(100000); } tiers_state = CC_TIER_STATE_READY; From 5127b64df83bb93e28ff018a5440d8f46aa6e2b6 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 18 Nov 2014 10:22:13 -0600 Subject: [PATCH 02/10] FS-7014: [mod_sofia] don't touch the tech_pvt when a call has just ended, leaving us with a null tech_pvt --- src/mod/endpoints/mod_sofia/sofia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 3bff27e1cd..c602d4273d 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -6693,6 +6693,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, case nua_callstate_received: case nua_callstate_proceeding: case nua_callstate_completing: + case nua_callstate_calling: if (!(session && channel && tech_pvt)) goto done; default: From 8330336e9a41e19bfe7af576eae55816b4ac4983 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Mon, 17 Nov 2014 11:37:15 -0500 Subject: [PATCH 03/10] 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 --- libs/.gitignore | 2 +- libs/apr/include/apr_ring.h | 24 + libs/unimrcp/.update | 2 +- libs/unimrcp/CHANGES | 214 ++++ libs/unimrcp/INSTALL | 197 +-- libs/unimrcp/Makefile.am | 44 +- libs/unimrcp/README | 30 +- libs/unimrcp/acinclude.m4 | 7 +- libs/unimrcp/build/Makefile.am | 6 +- libs/unimrcp/build/acmacros/apr.m4 | 51 +- libs/unimrcp/build/acmacros/apr_common.m4 | 990 +++++++++++++++ libs/unimrcp/build/acmacros/apu.m4 | 44 +- .../build/acmacros/ax_compiler_vendor.m4 | 41 + libs/unimrcp/build/acmacros/flite.m4 | 53 - libs/unimrcp/build/acmacros/pocketsphinx.m4 | 53 - libs/unimrcp/build/acmacros/sofia-sip.m4 | 85 +- libs/unimrcp/build/acmacros/sphinxbase.m4 | 50 - libs/unimrcp/build/acmacros/uni_plugin.m4 | 45 + libs/unimrcp/build/init.d/unimrcp-server | 541 ++++---- .../build/pkgconfig/unimrcpclient.pc.in | 2 +- .../build/pkgconfig/unimrcpplugin.pc.in | 2 +- .../build/pkgconfig/unimrcpserver.pc.in | 2 +- .../build/{vsprops => props}/apr.props | 58 +- .../build/{vsprops => props}/apt.props | 31 +- .../build/{vsprops => props}/mpf.props | 28 +- .../build/{vsprops => props}/mrcp.props | 31 +- .../build/{vsprops => props}/mrcpclient.props | 28 +- libs/unimrcp/build/props/mrcpengine.props | 15 + libs/unimrcp/build/props/mrcpserver.props | 16 + .../{vsprops => props}/mrcpsignaling.props | 25 +- .../{vsprops => props}/mrcpv2transport.props | 23 +- .../build/props/sdk/unimrcpclient.props | 14 + .../build/props/sdk/unimrcpplugin.props | 14 + libs/unimrcp/build/props/sdk/unimrcpsdk.props | 23 + .../build/props/sdk/unimrcpserver.props | 14 + .../build/{vsprops => props}/sofiasip.props | 42 +- .../build/{vsprops => props}/unibase.props | 55 +- libs/unimrcp/build/props/unibin-x64.props | 21 + libs/unimrcp/build/props/unibin.props | 18 + .../build/{vsprops => props}/unidebug.props | 42 +- libs/unimrcp/build/props/unilib-x64.props | 13 + libs/unimrcp/build/props/unilib.props | 8 + libs/unimrcp/build/props/unimrcpclient.props | 23 + libs/unimrcp/build/props/unimrcpserver.props | 23 + libs/unimrcp/build/props/uniplugin-x64.props | 22 + libs/unimrcp/build/props/uniplugin.props | 19 + .../build/{vsprops => props}/unirelease.props | 32 +- .../build/{vsprops => props}/unirtsp.props | 28 +- libs/unimrcp/build/rules/uniclientapp.am | 24 + libs/unimrcp/build/rules/uniclientlib.am | 30 + libs/unimrcp/build/rules/uniplugin.am | 14 + libs/unimrcp/build/rules/uniserverapp.am | 25 + libs/unimrcp/build/rules/uniserverlib.am | 32 + libs/unimrcp/build/svnrev/Makefile.am | 10 - libs/unimrcp/build/svnrev/svnrev.c | 381 ------ libs/unimrcp/build/svnrev/svnrev.input | 32 - libs/unimrcp/build/svnrev/svnrev.vcproj | 345 ------ libs/unimrcp/build/tools/prepare.2008.vcproj | 68 - libs/unimrcp/build/tools/prepare.vcproj | 8 +- libs/unimrcp/build/tools/prepare.vcxproj | 205 +++ libs/unimrcp/build/tools/preparesphinx.vcproj | 120 -- libs/unimrcp/build/tools/unimrcp_service.c | 307 ++++- .../build/tools/unimrcpservice.2008.vcproj | 158 --- libs/unimrcp/build/tools/unimrcpservice.rc | 39 + .../unimrcp/build/tools/unimrcpservice.vcproj | 36 + .../build/tools/unimrcpservice.vcxproj | 136 ++ .../tools/unimrcpservice.vcxproj.filters | 17 + libs/unimrcp/build/uni_revision.h | 43 + libs/unimrcp/build/uni_version.h | 68 +- libs/unimrcp/build/vsprops/flite.vsprops | 22 - .../build/vsprops/pocketsphinx.vsprops | 25 - libs/unimrcp/build/vsprops/sofiasip.vsprops | 2 +- libs/unimrcp/build/vsprops/unibin-x64.vsprops | 4 + libs/unimrcp/build/vsprops/unilib-x64.vsprops | 4 + .../build/vsprops/uniplugin-x64.vsprops | 4 + libs/unimrcp/conf/Makefile.am | 37 +- libs/unimrcp/conf/client-profiles/nuance.xml | 4 +- libs/unimrcp/conf/dirlayout.xml | 26 + libs/unimrcp/conf/unimrcpclient.xml | 18 +- libs/unimrcp/conf/unimrcpclient.xsd | 11 + libs/unimrcp/conf/unimrcpserver.xml | 20 +- libs/unimrcp/conf/unimrcpserver.xsd | 539 ++++---- libs/unimrcp/config.layout | 26 + libs/unimrcp/configure.ac | 388 +++--- libs/unimrcp/configure.gnu | 4 +- libs/unimrcp/data/Makefile.am | 34 +- libs/unimrcp/data/grammar.jsgf | 6 +- libs/unimrcp/data/grammar.mixed | 36 +- libs/unimrcp/data/grammar.srgs | 4 + libs/unimrcp/data/grammar.xml | 18 +- libs/unimrcp/data/result-verification.xml | 40 +- libs/unimrcp/data/result.xml | 12 +- libs/unimrcp/data/speak.xml | 10 +- libs/unimrcp/docs/mainpage.docs | 103 +- libs/unimrcp/libs/apr-toolkit/Makefile.am | 4 +- .../libs/apr-toolkit/aprtoolkit.2008.vcproj | 433 ------- .../libs/apr-toolkit/aprtoolkit.2012.vcxproj | 167 --- ...oolkit.2010.vcxproj => aprtoolkit.vcxproj} | 300 +++-- .../apr-toolkit/aprtoolkit.vcxproj.filters | 143 +++ libs/unimrcp/libs/apr-toolkit/include/apt.h | 4 +- .../apr-toolkit/include/apt_consumer_task.h | 20 +- .../apr-toolkit/include/apt_cyclic_queue.h | 4 +- .../libs/apr-toolkit/include/apt_dir_layout.h | 134 +- .../apr-toolkit/include/apt_header_field.h | 4 +- .../libs/apr-toolkit/include/apt_log.h | 45 +- .../include/apt_multipart_content.h | 4 +- .../libs/apr-toolkit/include/apt_net.h | 13 +- .../libs/apr-toolkit/include/apt_nlsml_doc.h | 192 ++- .../libs/apr-toolkit/include/apt_obj_list.h | 4 +- .../libs/apr-toolkit/include/apt_pair.h | 4 +- .../apr-toolkit/include/apt_poller_task.h | 20 +- .../libs/apr-toolkit/include/apt_pollset.h | 4 +- .../libs/apr-toolkit/include/apt_pool.h | 4 +- .../libs/apr-toolkit/include/apt_string.h | 15 +- .../apr-toolkit/include/apt_string_table.h | 4 +- .../libs/apr-toolkit/include/apt_task.h | 58 +- .../libs/apr-toolkit/include/apt_task_msg.h | 22 +- .../libs/apr-toolkit/include/apt_test_suite.h | 4 +- .../apr-toolkit/include/apt_text_message.h | 4 +- .../apr-toolkit/include/apt_text_stream.h | 10 +- .../apr-toolkit/include/apt_timer_queue.h | 4 +- .../libs/apr-toolkit/src/apt_consumer_task.c | 71 +- .../libs/apr-toolkit/src/apt_cyclic_queue.c | 4 +- .../libs/apr-toolkit/src/apt_dir_layout.c | 304 ++++- .../libs/apr-toolkit/src/apt_header_field.c | 14 +- libs/unimrcp/libs/apr-toolkit/src/apt_log.c | 37 +- .../apr-toolkit/src/apt_multipart_content.c | 4 +- libs/unimrcp/libs/apr-toolkit/src/apt_net.c | 107 +- .../libs/apr-toolkit/src/apt_nlsml_doc.c | 536 +++++++- .../libs/apr-toolkit/src/apt_obj_list.c | 4 +- libs/unimrcp/libs/apr-toolkit/src/apt_pair.c | 4 +- .../libs/apr-toolkit/src/apt_poller_task.c | 55 +- .../libs/apr-toolkit/src/apt_pollset.c | 4 +- libs/unimrcp/libs/apr-toolkit/src/apt_pool.c | 13 +- .../libs/apr-toolkit/src/apt_string_table.c | 4 +- libs/unimrcp/libs/apr-toolkit/src/apt_task.c | 318 +++-- .../libs/apr-toolkit/src/apt_task_msg.c | 4 +- .../libs/apr-toolkit/src/apt_test_suite.c | 8 +- .../libs/apr-toolkit/src/apt_text_message.c | 17 +- .../libs/apr-toolkit/src/apt_text_stream.c | 87 +- .../libs/apr-toolkit/src/apt_timer_queue.c | 110 +- libs/unimrcp/libs/mpf/Makefile.am | 6 +- libs/unimrcp/libs/mpf/codecs/g711/g711.c | 26 +- libs/unimrcp/libs/mpf/codecs/g711/g711.h | 81 +- libs/unimrcp/libs/mpf/include/mpf.h | 4 +- .../libs/mpf/include/mpf_activity_detector.h | 4 +- .../mpf/include/mpf_audio_file_descriptor.h | 4 +- .../libs/mpf/include/mpf_audio_file_stream.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_bridge.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_buffer.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_codec.h | 4 +- .../libs/mpf/include/mpf_codec_descriptor.h | 18 +- .../libs/mpf/include/mpf_codec_manager.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_context.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_decoder.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_encoder.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_engine.h | 4 +- .../libs/mpf/include/mpf_engine_factory.h | 48 + .../include/mpf_file_termination_factory.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_frame.h | 4 +- .../libs/mpf/include/mpf_frame_buffer.h | 8 +- .../libs/mpf/include/mpf_jitter_buffer.h | 7 +- libs/unimrcp/libs/mpf/include/mpf_message.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_mixer.h | 4 +- .../unimrcp/libs/mpf/include/mpf_multiplier.h | 4 +- .../libs/mpf/include/mpf_named_event.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_object.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_resampler.h | 4 +- .../libs/mpf/include/mpf_rtcp_packet.h | 4 +- .../libs/mpf/include/mpf_rtp_attribs.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_rtp_defs.h | 18 +- .../libs/mpf/include/mpf_rtp_descriptor.h | 20 +- .../unimrcp/libs/mpf/include/mpf_rtp_header.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_rtp_pt.h | 14 +- libs/unimrcp/libs/mpf/include/mpf_rtp_stat.h | 4 +- .../unimrcp/libs/mpf/include/mpf_rtp_stream.h | 4 +- .../mpf/include/mpf_rtp_termination_factory.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_scheduler.h | 4 +- libs/unimrcp/libs/mpf/include/mpf_stream.h | 4 +- .../libs/mpf/include/mpf_stream_descriptor.h | 4 +- .../libs/mpf/include/mpf_termination.h | 8 +- .../mpf/include/mpf_termination_factory.h | 15 +- libs/unimrcp/libs/mpf/include/mpf_trace.h | 51 + libs/unimrcp/libs/mpf/include/mpf_types.h | 7 +- libs/unimrcp/libs/mpf/mpf.2008.vcproj | 559 --------- .../unimrcp/libs/mpf/mpf.2010.vcxproj.filters | 239 ---- libs/unimrcp/libs/mpf/mpf.2012.vcxproj | 195 --- libs/unimrcp/libs/mpf/mpf.vcproj | 1096 +++++++++-------- .../mpf/{mpf.2010.vcxproj => mpf.vcxproj} | 389 +++--- ...12.vcxproj.filters => mpf.vcxproj.filters} | 472 +++---- .../libs/mpf/src/mpf_activity_detector.c | 4 +- .../libs/mpf/src/mpf_audio_file_stream.c | 7 +- libs/unimrcp/libs/mpf/src/mpf_bridge.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_buffer.c | 10 +- .../libs/mpf/src/mpf_codec_descriptor.c | 29 +- libs/unimrcp/libs/mpf/src/mpf_codec_g711.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_codec_linear.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_codec_manager.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_context.c | 5 +- libs/unimrcp/libs/mpf/src/mpf_decoder.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_dtmf_detector.c | 8 +- .../unimrcp/libs/mpf/src/mpf_dtmf_generator.c | 13 +- libs/unimrcp/libs/mpf/src/mpf_encoder.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_engine.c | 18 +- .../unimrcp/libs/mpf/src/mpf_engine_factory.c | 78 ++ .../mpf/src/mpf_file_termination_factory.c | 5 +- libs/unimrcp/libs/mpf/src/mpf_frame_buffer.c | 56 +- libs/unimrcp/libs/mpf/src/mpf_jitter_buffer.c | 281 ++++- libs/unimrcp/libs/mpf/src/mpf_mixer.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_multiplier.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_named_event.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_resampler.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_rtp_attribs.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_rtp_stream.c | 278 +++-- .../mpf/src/mpf_rtp_termination_factory.c | 94 +- libs/unimrcp/libs/mpf/src/mpf_scheduler.c | 9 +- libs/unimrcp/libs/mpf/src/mpf_stream.c | 4 +- libs/unimrcp/libs/mpf/src/mpf_termination.c | 6 +- .../libs/mpf/src/mpf_termination_factory.c | 15 +- libs/unimrcp/libs/mrcp-client/Makefile.am | 4 +- .../mrcp-client/include/mrcp_application.h | 10 +- .../libs/mrcp-client/include/mrcp_client.h | 33 +- .../mrcp-client/include/mrcp_client_session.h | 25 +- .../mrcp-client/include/mrcp_client_types.h | 4 +- .../libs/mrcp-client/mrcpclient.2008.vcproj | 293 ----- ...client.2010.vcxproj => mrcpclient.vcxproj} | 245 ++-- .../mrcpclient.vcxproj.filters} | 71 +- .../libs/mrcp-client/src/mrcp_application.c | 23 +- .../libs/mrcp-client/src/mrcp_client.c | 188 ++- .../mrcp-client/src/mrcp_client_session.c | 227 ++-- libs/unimrcp/libs/mrcp-engine/Makefile.am | 4 +- .../mrcp-engine/include/mrcp_engine_factory.h | 4 +- .../mrcp-engine/include/mrcp_engine_iface.h | 4 +- .../mrcp-engine/include/mrcp_engine_impl.h | 4 +- .../mrcp-engine/include/mrcp_engine_loader.h | 4 +- .../mrcp-engine/include/mrcp_engine_plugin.h | 20 +- .../mrcp-engine/include/mrcp_engine_types.h | 4 +- .../mrcp-engine/include/mrcp_recog_engine.h | 4 +- .../include/mrcp_recog_state_machine.h | 4 +- .../include/mrcp_recorder_engine.h | 4 +- .../include/mrcp_recorder_state_machine.h | 4 +- .../include/mrcp_resource_engine.h | 4 +- .../mrcp-engine/include/mrcp_state_machine.h | 4 +- .../mrcp-engine/include/mrcp_synth_engine.h | 4 +- .../include/mrcp_synth_state_machine.h | 4 +- .../include/mrcp_verifier_engine.h | 4 +- .../include/mrcp_verifier_state_machine.h | 4 +- .../libs/mrcp-engine/mrcpengine.2008.vcproj | 238 ---- .../libs/mrcp-engine/mrcpengine.vcxproj | 142 +++ .../mrcp-engine/mrcpengine.vcxproj.filters | 89 ++ .../mrcp-engine/src/mrcp_engine_factory.c | 4 +- .../libs/mrcp-engine/src/mrcp_engine_iface.c | 6 +- .../libs/mrcp-engine/src/mrcp_engine_impl.c | 4 +- .../libs/mrcp-engine/src/mrcp_engine_loader.c | 5 +- .../src/mrcp_recog_state_machine.c | 11 +- .../src/mrcp_recorder_state_machine.c | 7 +- .../src/mrcp_synth_state_machine.c | 11 +- .../src/mrcp_verifier_state_machine.c | 7 +- libs/unimrcp/libs/mrcp-server/Makefile.am | 4 +- .../libs/mrcp-server/include/mrcp_server.h | 5 +- .../mrcp-server/include/mrcp_server_session.h | 6 +- .../mrcp-server/include/mrcp_server_types.h | 4 +- .../libs/mrcp-server/mrcpserver.2008.vcproj | 162 --- .../libs/mrcp-server/mrcpserver.vcxproj | 127 ++ .../mrcp-server/mrcpserver.vcxproj.filters} | 65 +- .../libs/mrcp-server/src/mrcp_server.c | 33 +- .../mrcp-server/src/mrcp_server_session.c | 38 +- libs/unimrcp/libs/mrcp-signaling/Makefile.am | 6 +- .../mrcp-signaling/include/mrcp_session.h | 16 +- .../include/mrcp_session_descriptor.h | 10 +- .../mrcp-signaling/include/mrcp_sig_agent.h | 22 +- .../mrcp-signaling/include/mrcp_sig_types.h | 7 +- .../mrcp-signaling/mrcpsignaling.2008.vcproj | 289 ----- ...ing.2010.vcxproj => mrcpsignaling.vcxproj} | 243 ++-- ....filters => mrcpsignaling.vcxproj.filters} | 68 +- .../src/mrcp_session_descriptor.c | 5 +- .../libs/mrcp-signaling/src/mrcp_sig_agent.c | 56 +- libs/unimrcp/libs/mrcp/Makefile.am | 4 +- .../libs/mrcp/control/include/mrcp_resource.h | 4 +- .../control/include/mrcp_resource_factory.h | 4 +- .../control/include/mrcp_resource_loader.h | 4 +- .../libs/mrcp/control/include/mrcp_stream.h | 4 +- .../mrcp/control/src/mrcp_resource_factory.c | 4 +- .../mrcp/control/src/mrcp_resource_loader.c | 4 +- .../libs/mrcp/control/src/mrcp_stream.c | 4 +- libs/unimrcp/libs/mrcp/include/mrcp.h | 4 +- libs/unimrcp/libs/mrcp/include/mrcp_types.h | 4 +- .../message/include/mrcp_generic_header.h | 4 +- .../libs/mrcp/message/include/mrcp_header.h | 6 +- .../message/include/mrcp_header_accessor.h | 4 +- .../libs/mrcp/message/include/mrcp_message.h | 4 +- .../mrcp/message/include/mrcp_start_line.h | 8 +- .../mrcp/message/src/mrcp_generic_header.c | 37 +- .../libs/mrcp/message/src/mrcp_header.c | 132 +- .../mrcp/message/src/mrcp_header_accessor.c | 4 +- .../libs/mrcp/message/src/mrcp_message.c | 4 +- .../libs/mrcp/message/src/mrcp_start_line.c | 6 +- libs/unimrcp/libs/mrcp/mrcp.2008.vcproj | 446 ------- .../libs/mrcp/mrcp.2010.vcxproj.filters | 133 -- libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj | 158 --- .../mrcp/{mrcp.2010.vcxproj => mrcp.vcxproj} | 309 ++--- ...2.vcxproj.filters => mrcp.vcxproj.filters} | 302 ++--- .../resources/include/mrcp_recog_header.h | 4 +- .../resources/include/mrcp_recog_resource.h | 4 +- .../resources/include/mrcp_recorder_header.h | 4 +- .../include/mrcp_recorder_resource.h | 4 +- .../resources/include/mrcp_synth_header.h | 8 +- .../resources/include/mrcp_synth_resource.h | 4 +- .../resources/include/mrcp_verifier_header.h | 2 +- .../include/mrcp_verifier_resource.h | 2 +- .../mrcp/resources/src/mrcp_recog_header.c | 4 +- .../mrcp/resources/src/mrcp_recog_resource.c | 4 +- .../mrcp/resources/src/mrcp_recorder_header.c | 4 +- .../resources/src/mrcp_recorder_resource.c | 4 +- .../mrcp/resources/src/mrcp_synth_header.c | 39 +- .../mrcp/resources/src/mrcp_synth_resource.c | 4 +- .../mrcp/resources/src/mrcp_verifier_header.c | 2 +- .../resources/src/mrcp_verifier_resource.c | 2 +- .../unimrcp/libs/mrcpv2-transport/Makefile.am | 10 +- .../include/mrcp_ca_factory.h | 45 + .../include/mrcp_client_connection.h | 4 +- .../include/mrcp_connection.h | 16 +- .../include/mrcp_connection_types.h | 7 +- .../include/mrcp_control_descriptor.h | 4 +- .../include/mrcp_server_connection.h | 4 +- .../mrcpv2transport.2008.vcproj | 301 ----- .../mrcpv2transport.2012.vcxproj | 128 -- .../mrcpv2-transport/mrcpv2transport.vcproj | 8 + ...t.2010.vcxproj => mrcpv2transport.vcxproj} | 247 ++-- ...ilters => mrcpv2transport.vcxproj.filters} | 92 +- .../mrcpv2-transport/src/mrcp_ca_factory.c | 65 + .../src/mrcp_client_connection.c | 60 +- .../mrcpv2-transport/src/mrcp_connection.c | 8 +- .../src/mrcp_control_descriptor.c | 4 +- .../src/mrcp_server_connection.c | 196 ++- libs/unimrcp/libs/uni-rtsp/Makefile.am | 4 +- libs/unimrcp/libs/uni-rtsp/include/rtsp.h | 4 +- .../libs/uni-rtsp/include/rtsp_client.h | 16 +- .../libs/uni-rtsp/include/rtsp_header.h | 4 +- .../libs/uni-rtsp/include/rtsp_message.h | 4 +- .../libs/uni-rtsp/include/rtsp_server.h | 18 +- .../libs/uni-rtsp/include/rtsp_start_line.h | 4 +- .../libs/uni-rtsp/include/rtsp_stream.h | 4 +- libs/unimrcp/libs/uni-rtsp/src/rtsp_client.c | 114 +- libs/unimrcp/libs/uni-rtsp/src/rtsp_header.c | 4 +- libs/unimrcp/libs/uni-rtsp/src/rtsp_message.c | 4 +- libs/unimrcp/libs/uni-rtsp/src/rtsp_server.c | 121 +- .../libs/uni-rtsp/src/rtsp_start_line.c | 4 +- libs/unimrcp/libs/uni-rtsp/src/rtsp_stream.c | 4 +- .../unimrcp/libs/uni-rtsp/unirtsp.2008.vcproj | 321 ----- .../libs/uni-rtsp/unirtsp.2012.vcxproj | 136 -- .../uni-rtsp/unirtsp.2012.vcxproj.filters | 56 - libs/unimrcp/libs/uni-rtsp/unirtsp.vcproj | 4 - .../{unirtsp.2010.vcxproj => unirtsp.vcxproj} | 257 ++-- ...cxproj.filters => unirtsp.vcxproj.filters} | 110 +- .../unimrcp/modules/mrcp-sofiasip/Makefile.am | 10 +- .../modules/mrcp-sofiasip/include/mrcp_sdp.h | 6 +- .../include/mrcp_sofiasip_client_agent.h | 13 +- .../include/mrcp_sofiasip_server_agent.h | 13 +- .../mrcp-sofiasip/mrcpsofiasip.2008.vcproj | 293 ----- .../mrcp-sofiasip/mrcpsofiasip.2012.vcxproj | 142 --- .../modules/mrcp-sofiasip/mrcpsofiasip.vcproj | 8 + ...asip.2010.vcxproj => mrcpsofiasip.vcxproj} | 283 ++--- ...j.filters => mrcpsofiasip.vcxproj.filters} | 71 +- .../modules/mrcp-sofiasip/src/mrcp_sdp.c | 77 +- .../src/mrcp_sofiasip_client_agent.c | 190 +-- .../mrcp-sofiasip/src/mrcp_sofiasip_logger.c | 92 ++ .../src/mrcp_sofiasip_server_agent.c | 89 +- libs/unimrcp/modules/mrcp-unirtsp/Makefile.am | 7 +- .../include/mrcp_unirtsp_client_agent.h | 4 +- .../mrcp-unirtsp/include/mrcp_unirtsp_sdp.h | 4 +- .../include/mrcp_unirtsp_server_agent.h | 4 +- .../mrcp-unirtsp/mrcpunirtsp.2008.vcproj | 293 ----- ...irtsp.2010.vcxproj => mrcpunirtsp.vcxproj} | 277 +++-- ...oj.filters => mrcpunirtsp.vcxproj.filters} | 68 +- .../src/mrcp_unirtsp_client_agent.c | 22 +- .../mrcp-unirtsp/src/mrcp_unirtsp_sdp.c | 77 +- .../src/mrcp_unirtsp_server_agent.c | 32 +- libs/unimrcp/packages/inno-setup/setup.txt | 4 +- .../packages/inno-setup/unimrcp-sdk.iss | 17 +- libs/unimrcp/packages/inno-setup/unimrcp.iss | 7 +- libs/unimrcp/platforms/Makefile.am | 29 +- libs/unimrcp/platforms/asr-client/Makefile.am | 28 +- .../platforms/asr-client/asrclient.vcxproj | 136 ++ .../asr-client/asrclient.vcxproj.filters | 18 + libs/unimrcp/platforms/asr-client/src/main.c | 10 +- .../platforms/libasr-client/Makefile.am | 23 +- .../libasr-client/include/asr_engine.h | 4 +- .../libasr-client/libasrclient.vcxproj} | 285 ++--- .../libasrclient.vcxproj.filters | 23 + .../platforms/libasr-client/src/asr_engine.c | 77 +- .../platforms/libunimrcp-client/Makefile.am | 31 +- .../include/unimrcp_client.h | 10 +- .../libunimrcpclient.2008.vcproj | 160 --- .../libunimrcpclient.vcxproj | 140 +++ .../libunimrcpclient.vcxproj.filters | 29 + .../libunimrcp-client/src/unimrcp_client.c | 467 +++++-- .../platforms/libunimrcp-server/Makefile.am | 33 +- .../include/unimrcp_server.h | 4 +- .../libunimrcpserver.2008.vcproj | 160 --- .../libunimrcpserver.vcxproj | 140 +++ .../libunimrcpserver.vcxproj.filters | 29 + .../libunimrcp-server/src/unimrcp_server.c | 146 ++- libs/unimrcp/platforms/umc/Makefile.am | 26 +- .../platforms/umc/include/dtmfscenario.h | 4 +- .../platforms/umc/include/dtmfsession.h | 6 +- .../platforms/umc/include/recogscenario.h | 11 +- .../platforms/umc/include/recogsession.h | 6 +- .../platforms/umc/include/recorderscenario.h | 4 +- .../platforms/umc/include/recordersession.h | 4 +- .../platforms/umc/include/setparamscenario.h | 4 +- .../platforms/umc/include/setparamsession.h | 4 +- .../platforms/umc/include/synthscenario.h | 4 +- .../platforms/umc/include/synthsession.h | 4 +- .../platforms/umc/include/umcconsole.h | 15 +- .../platforms/umc/include/umcframework.h | 4 +- .../platforms/umc/include/umcscenario.h | 15 +- .../platforms/umc/include/umcsession.h | 4 +- .../platforms/umc/include/verifierscenario.h | 4 +- .../platforms/umc/include/verifiersession.h | 4 +- .../platforms/umc/src/dtmfscenario.cpp | 4 +- .../unimrcp/platforms/umc/src/dtmfsession.cpp | 40 +- libs/unimrcp/platforms/umc/src/main.cpp | 4 +- .../platforms/umc/src/recogscenario.cpp | 7 +- .../platforms/umc/src/recogsession.cpp | 55 +- .../platforms/umc/src/recorderscenario.cpp | 4 +- .../platforms/umc/src/recordersession.cpp | 16 +- .../platforms/umc/src/setparamscenario.cpp | 4 +- .../platforms/umc/src/setparamsession.cpp | 5 +- .../platforms/umc/src/synthscenario.cpp | 4 +- .../platforms/umc/src/synthsession.cpp | 33 +- libs/unimrcp/platforms/umc/src/umcconsole.cpp | 68 +- .../platforms/umc/src/umcframework.cpp | 11 +- .../unimrcp/platforms/umc/src/umcscenario.cpp | 17 +- libs/unimrcp/platforms/umc/src/umcsession.cpp | 4 +- .../platforms/umc/src/verifierscenario.cpp | 4 +- .../platforms/umc/src/verifiersession.cpp | 17 +- libs/unimrcp/platforms/umc/umc.rc | 78 +- libs/unimrcp/platforms/umc/umc.vcxproj | 176 +++ .../unimrcp/platforms/umc/umc.vcxproj.filters | 119 ++ .../platforms/unimrcp-client/Makefile.am | 25 +- .../unimrcp-client/include/demo_application.h | 4 +- .../unimrcp-client/include/demo_framework.h | 4 +- .../unimrcp-client/include/demo_util.h | 7 +- .../src/demo_bypass_application.c | 8 +- .../src/demo_discover_application.c | 4 +- .../unimrcp-client/src/demo_framework.c | 10 +- .../src/demo_recog_application.c | 33 +- .../src/demo_synth_application.c | 36 +- .../platforms/unimrcp-client/src/demo_util.c | 38 +- .../platforms/unimrcp-client/src/main.c | 77 +- .../unimrcp-client/unimrcpclient.2008.vcproj | 200 --- .../platforms/unimrcp-client/unimrcpclient.rc | 78 +- .../unimrcp-client/unimrcpclient.vcxproj | 153 +++ .../unimrcpclient.vcxproj.filters} | 92 +- .../platforms/unimrcp-server/Makefile.am | 24 +- .../platforms/unimrcp-server/src/main.c | 100 +- .../unimrcp-server/src/uni_cmdline.c | 6 +- .../platforms/unimrcp-server/src/uni_daemon.c | 4 +- .../unimrcp-server/src/uni_service.c | 47 +- .../unimrcp-server/unimrcpserver.2008.vcproj | 174 --- .../platforms/unimrcp-server/unimrcpserver.rc | 78 +- .../unimrcp-server/unimrcpserver.vcxproj | 135 ++ .../unimrcpserver.vcxproj.filters} | 63 +- libs/unimrcp/plugins/Makefile.am | 8 - libs/unimrcp/plugins/demo-recog/Makefile.am | 16 +- .../plugins/demo-recog/demorecog.2008.vcproj | 164 --- .../demo-recog/demorecog.vcxproj} | 248 ++-- .../demo-recog/demorecog.vcxproj.filters | 18 + .../demo-recog/src/demo_recog_engine.c | 26 +- libs/unimrcp/plugins/demo-synth/Makefile.am | 16 +- .../plugins/demo-synth/demosynth.2008.vcproj | 164 --- .../plugins/demo-synth/demosynth.vcxproj | 123 ++ .../demo-synth/demosynth.vcxproj.filters | 18 + .../demo-synth/src/demo_synth_engine.c | 23 +- .../unimrcp/plugins/demo-verifier/Makefile.am | 16 +- .../demo-verifier/demoverifier.vcxproj | 123 ++ .../demoverifier.vcxproj.filters | 18 + .../demo-verifier/src/demo_verifier_engine.c | 26 +- libs/unimrcp/plugins/mrcp-flite/Makefile.am | 19 - .../plugins/mrcp-flite/include/flite_voices.h | 47 - .../plugins/mrcp-flite/mrcpflite.2008.vcproj | 172 --- .../plugins/mrcp-flite/mrcpflite.vcproj | 304 ----- .../plugins/mrcp-flite/src/flite_voices.c | 162 --- .../plugins/mrcp-flite/src/mrcp_flite.c | 622 ---------- .../plugins/mrcp-pocketsphinx/Makefile.am | 36 - .../mrcp-pocketsphinx/conf/pocketsphinx.xml | 25 - .../include/pocketsphinx_properties.h | 81 -- .../mrcppocketsphinx.2008.vcproj | 172 --- .../mrcp-pocketsphinx/mrcppocketsphinx.vcproj | 304 ----- .../mrcp-pocketsphinx/src/mrcp_pocketsphinx.c | 1002 --------------- .../src/pocketsphinx_properties.c | 215 ---- .../unimrcp/plugins/mrcp-recorder/Makefile.am | 16 +- .../mrcp-recorder/mrcprecorder.vcxproj | 123 ++ .../mrcprecorder.vcxproj.filters | 18 + .../mrcp-recorder/src/mrcp_recorder_engine.c | 23 +- libs/unimrcp/tests/apttest/Makefile.am | 4 +- .../unimrcp/tests/apttest/apttest.2008.vcproj | 174 --- libs/unimrcp/tests/apttest/apttest.vcxproj | 127 ++ .../tests/apttest/apttest.vcxproj.filters | 27 + .../tests/apttest/src/consumer_task_suite.c | 4 +- libs/unimrcp/tests/apttest/src/main.c | 4 +- .../tests/apttest/src/multipart_suite.c | 4 +- libs/unimrcp/tests/apttest/src/task_suite.c | 4 +- libs/unimrcp/tests/mpftest/Makefile.am | 4 +- .../unimrcp/tests/mpftest/mpftest.2008.vcproj | 166 --- libs/unimrcp/tests/mpftest/mpftest.vcxproj | 125 ++ .../tests/mpftest/mpftest.vcxproj.filters | 21 + libs/unimrcp/tests/mpftest/src/main.c | 4 +- libs/unimrcp/tests/mpftest/src/mpf_suite.c | 512 +++++--- libs/unimrcp/tests/mrcptest/Makefile.am | 4 +- .../tests/mrcptest/mrcptest.2008.vcproj | 174 --- libs/unimrcp/tests/mrcptest/mrcptest.vcxproj | 127 ++ .../tests/mrcptest/mrcptest.vcxproj.filters | 27 + libs/unimrcp/tests/mrcptest/src/main.c | 4 +- .../tests/mrcptest/src/parse_gen_suite.c | 9 +- .../tests/mrcptest/src/set_get_suite.c | 4 +- .../mrcptest/src/transparent_set_get_suite.c | 4 +- libs/unimrcp/tests/rtsptest/Makefile.am | 4 +- .../tests/rtsptest/rtsptest.2008.vcproj | 166 --- .../rtsptest/rtsptest.vcxproj} | 251 ++-- .../tests/rtsptest/rtsptest.vcxproj.filters | 21 + libs/unimrcp/tests/rtsptest/src/main.c | 4 +- .../tests/rtsptest/src/parse_gen_suite.c | 9 +- libs/unimrcp/tests/strtablegen/Makefile.am | 6 +- libs/unimrcp/tests/strtablegen/src/main.c | 4 +- .../tests/strtablegen/strtablegen.2008.vcproj | 162 --- .../tests/strtablegen/strtablegen.vcxproj | 124 ++ .../strtablegen/strtablegen.vcxproj.filters | 18 + libs/unimrcp/unimrcp-2010.sln | 358 ++++++ libs/unimrcp/unimrcp.2008.sln | 292 ----- libs/unimrcp/unimrcp.sln | 42 +- src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 456 ++++--- 533 files changed, 16389 insertions(+), 19000 deletions(-) create mode 100644 libs/unimrcp/CHANGES create mode 100644 libs/unimrcp/build/acmacros/apr_common.m4 create mode 100644 libs/unimrcp/build/acmacros/ax_compiler_vendor.m4 delete mode 100644 libs/unimrcp/build/acmacros/flite.m4 delete mode 100644 libs/unimrcp/build/acmacros/pocketsphinx.m4 delete mode 100644 libs/unimrcp/build/acmacros/sphinxbase.m4 create mode 100644 libs/unimrcp/build/acmacros/uni_plugin.m4 rename libs/unimrcp/build/{vsprops => props}/apr.props (76%) rename libs/unimrcp/build/{vsprops => props}/apt.props (72%) rename libs/unimrcp/build/{vsprops => props}/mpf.props (67%) rename libs/unimrcp/build/{vsprops => props}/mrcp.props (76%) rename libs/unimrcp/build/{vsprops => props}/mrcpclient.props (96%) create mode 100644 libs/unimrcp/build/props/mrcpengine.props create mode 100644 libs/unimrcp/build/props/mrcpserver.props rename libs/unimrcp/build/{vsprops => props}/mrcpsignaling.props (63%) rename libs/unimrcp/build/{vsprops => props}/mrcpv2transport.props (70%) create mode 100644 libs/unimrcp/build/props/sdk/unimrcpclient.props create mode 100644 libs/unimrcp/build/props/sdk/unimrcpplugin.props create mode 100644 libs/unimrcp/build/props/sdk/unimrcpsdk.props create mode 100644 libs/unimrcp/build/props/sdk/unimrcpserver.props rename libs/unimrcp/build/{vsprops => props}/sofiasip.props (66%) rename libs/unimrcp/build/{vsprops => props}/unibase.props (88%) create mode 100644 libs/unimrcp/build/props/unibin-x64.props create mode 100644 libs/unimrcp/build/props/unibin.props rename libs/unimrcp/build/{vsprops => props}/unidebug.props (71%) create mode 100644 libs/unimrcp/build/props/unilib-x64.props create mode 100644 libs/unimrcp/build/props/unilib.props create mode 100644 libs/unimrcp/build/props/unimrcpclient.props create mode 100644 libs/unimrcp/build/props/unimrcpserver.props create mode 100644 libs/unimrcp/build/props/uniplugin-x64.props create mode 100644 libs/unimrcp/build/props/uniplugin.props rename libs/unimrcp/build/{vsprops => props}/unirelease.props (77%) rename libs/unimrcp/build/{vsprops => props}/unirtsp.props (86%) create mode 100644 libs/unimrcp/build/rules/uniclientapp.am create mode 100644 libs/unimrcp/build/rules/uniclientlib.am create mode 100644 libs/unimrcp/build/rules/uniplugin.am create mode 100644 libs/unimrcp/build/rules/uniserverapp.am create mode 100644 libs/unimrcp/build/rules/uniserverlib.am delete mode 100644 libs/unimrcp/build/svnrev/Makefile.am delete mode 100644 libs/unimrcp/build/svnrev/svnrev.c delete mode 100644 libs/unimrcp/build/svnrev/svnrev.input delete mode 100644 libs/unimrcp/build/svnrev/svnrev.vcproj delete mode 100644 libs/unimrcp/build/tools/prepare.2008.vcproj create mode 100644 libs/unimrcp/build/tools/prepare.vcxproj delete mode 100644 libs/unimrcp/build/tools/preparesphinx.vcproj delete mode 100644 libs/unimrcp/build/tools/unimrcpservice.2008.vcproj create mode 100644 libs/unimrcp/build/tools/unimrcpservice.rc create mode 100644 libs/unimrcp/build/tools/unimrcpservice.vcxproj create mode 100644 libs/unimrcp/build/tools/unimrcpservice.vcxproj.filters create mode 100644 libs/unimrcp/build/uni_revision.h delete mode 100644 libs/unimrcp/build/vsprops/flite.vsprops delete mode 100644 libs/unimrcp/build/vsprops/pocketsphinx.vsprops create mode 100644 libs/unimrcp/conf/dirlayout.xml create mode 100644 libs/unimrcp/config.layout mode change 100644 => 100755 libs/unimrcp/configure.gnu create mode 100644 libs/unimrcp/data/grammar.srgs delete mode 100644 libs/unimrcp/libs/apr-toolkit/aprtoolkit.2008.vcproj delete mode 100644 libs/unimrcp/libs/apr-toolkit/aprtoolkit.2012.vcxproj rename libs/unimrcp/libs/apr-toolkit/{aprtoolkit.2010.vcxproj => aprtoolkit.vcxproj} (64%) create mode 100644 libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj.filters create mode 100644 libs/unimrcp/libs/mpf/include/mpf_engine_factory.h create mode 100644 libs/unimrcp/libs/mpf/include/mpf_trace.h delete mode 100644 libs/unimrcp/libs/mpf/mpf.2008.vcproj delete mode 100644 libs/unimrcp/libs/mpf/mpf.2010.vcxproj.filters delete mode 100644 libs/unimrcp/libs/mpf/mpf.2012.vcxproj rename libs/unimrcp/libs/mpf/{mpf.2010.vcxproj => mpf.vcxproj} (78%) rename libs/unimrcp/libs/mpf/{mpf.2012.vcxproj.filters => mpf.vcxproj.filters} (93%) create mode 100644 libs/unimrcp/libs/mpf/src/mpf_engine_factory.c delete mode 100644 libs/unimrcp/libs/mrcp-client/mrcpclient.2008.vcproj rename libs/unimrcp/libs/mrcp-client/{mrcpclient.2010.vcxproj => mrcpclient.vcxproj} (64%) rename libs/unimrcp/libs/{mrcp-signaling/mrcpsignaling.2012.vcxproj.filters => mrcp-client/mrcpclient.vcxproj.filters} (63%) delete mode 100644 libs/unimrcp/libs/mrcp-engine/mrcpengine.2008.vcproj create mode 100644 libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj create mode 100644 libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj.filters delete mode 100644 libs/unimrcp/libs/mrcp-server/mrcpserver.2008.vcproj create mode 100644 libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj rename libs/unimrcp/{modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj.filters => libs/mrcp-server/mrcpserver.vcxproj.filters} (61%) delete mode 100644 libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2008.vcproj rename libs/unimrcp/libs/mrcp-signaling/{mrcpsignaling.2010.vcxproj => mrcpsignaling.vcxproj} (64%) rename libs/unimrcp/libs/mrcp-signaling/{mrcpsignaling.2010.vcxproj.filters => mrcpsignaling.vcxproj.filters} (91%) delete mode 100644 libs/unimrcp/libs/mrcp/mrcp.2008.vcproj delete mode 100644 libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj.filters delete mode 100644 libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj rename libs/unimrcp/libs/mrcp/{mrcp.2010.vcxproj => mrcp.vcxproj} (75%) rename libs/unimrcp/libs/mrcp/{mrcp.2012.vcxproj.filters => mrcp.vcxproj.filters} (83%) create mode 100644 libs/unimrcp/libs/mrcpv2-transport/include/mrcp_ca_factory.h delete mode 100644 libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2008.vcproj delete mode 100644 libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj rename libs/unimrcp/libs/mrcpv2-transport/{mrcpv2transport.2010.vcxproj => mrcpv2transport.vcxproj} (65%) rename libs/unimrcp/libs/mrcpv2-transport/{mrcpv2transport.2012.vcxproj.filters => mrcpv2transport.vcxproj.filters} (84%) create mode 100644 libs/unimrcp/libs/mrcpv2-transport/src/mrcp_ca_factory.c delete mode 100644 libs/unimrcp/libs/uni-rtsp/unirtsp.2008.vcproj delete mode 100644 libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj delete mode 100644 libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj.filters rename libs/unimrcp/libs/uni-rtsp/{unirtsp.2010.vcxproj => unirtsp.vcxproj} (63%) rename libs/unimrcp/libs/uni-rtsp/{unirtsp.2010.vcxproj.filters => unirtsp.vcxproj.filters} (93%) delete mode 100644 libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2008.vcproj delete mode 100644 libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj rename libs/unimrcp/modules/mrcp-sofiasip/{mrcpsofiasip.2010.vcxproj => mrcpsofiasip.vcxproj} (62%) rename libs/unimrcp/modules/mrcp-sofiasip/{mrcpsofiasip.2010.vcxproj.filters => mrcpsofiasip.vcxproj.filters} (86%) create mode 100644 libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_logger.c delete mode 100644 libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2008.vcproj rename libs/unimrcp/modules/mrcp-unirtsp/{mrcpunirtsp.2010.vcxproj => mrcpunirtsp.vcxproj} (63%) rename libs/unimrcp/modules/mrcp-unirtsp/{mrcpunirtsp.2010.vcxproj.filters => mrcpunirtsp.vcxproj.filters} (91%) create mode 100644 libs/unimrcp/platforms/asr-client/asrclient.vcxproj create mode 100644 libs/unimrcp/platforms/asr-client/asrclient.vcxproj.filters rename libs/unimrcp/{modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj => platforms/libasr-client/libasrclient.vcxproj} (54%) create mode 100644 libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj.filters delete mode 100644 libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.2008.vcproj create mode 100644 libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj create mode 100644 libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj.filters delete mode 100644 libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.2008.vcproj create mode 100644 libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj create mode 100644 libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj.filters create mode 100644 libs/unimrcp/platforms/umc/umc.vcxproj create mode 100644 libs/unimrcp/platforms/umc/umc.vcxproj.filters delete mode 100644 libs/unimrcp/platforms/unimrcp-client/unimrcpclient.2008.vcproj create mode 100644 libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj rename libs/unimrcp/{libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj.filters => platforms/unimrcp-client/unimrcpclient.vcxproj.filters} (52%) delete mode 100644 libs/unimrcp/platforms/unimrcp-server/unimrcpserver.2008.vcproj create mode 100644 libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj rename libs/unimrcp/{modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj.filters => platforms/unimrcp-server/unimrcpserver.vcxproj.filters} (52%) delete mode 100644 libs/unimrcp/plugins/demo-recog/demorecog.2008.vcproj rename libs/unimrcp/{libs/mrcp-signaling/mrcpsignaling.2012.vcxproj => plugins/demo-recog/demorecog.vcxproj} (57%) create mode 100644 libs/unimrcp/plugins/demo-recog/demorecog.vcxproj.filters delete mode 100644 libs/unimrcp/plugins/demo-synth/demosynth.2008.vcproj create mode 100644 libs/unimrcp/plugins/demo-synth/demosynth.vcxproj create mode 100644 libs/unimrcp/plugins/demo-synth/demosynth.vcxproj.filters create mode 100644 libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj create mode 100644 libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj.filters delete mode 100644 libs/unimrcp/plugins/mrcp-flite/Makefile.am delete mode 100644 libs/unimrcp/plugins/mrcp-flite/include/flite_voices.h delete mode 100644 libs/unimrcp/plugins/mrcp-flite/mrcpflite.2008.vcproj delete mode 100644 libs/unimrcp/plugins/mrcp-flite/mrcpflite.vcproj delete mode 100644 libs/unimrcp/plugins/mrcp-flite/src/flite_voices.c delete mode 100644 libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/conf/pocketsphinx.xml delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/include/pocketsphinx_properties.h delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.2008.vcproj delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c delete mode 100644 libs/unimrcp/plugins/mrcp-pocketsphinx/src/pocketsphinx_properties.c create mode 100644 libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj create mode 100644 libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj.filters delete mode 100644 libs/unimrcp/tests/apttest/apttest.2008.vcproj create mode 100644 libs/unimrcp/tests/apttest/apttest.vcxproj create mode 100644 libs/unimrcp/tests/apttest/apttest.vcxproj.filters delete mode 100644 libs/unimrcp/tests/mpftest/mpftest.2008.vcproj create mode 100644 libs/unimrcp/tests/mpftest/mpftest.vcxproj create mode 100644 libs/unimrcp/tests/mpftest/mpftest.vcxproj.filters delete mode 100644 libs/unimrcp/tests/mrcptest/mrcptest.2008.vcproj create mode 100644 libs/unimrcp/tests/mrcptest/mrcptest.vcxproj create mode 100644 libs/unimrcp/tests/mrcptest/mrcptest.vcxproj.filters delete mode 100644 libs/unimrcp/tests/rtsptest/rtsptest.2008.vcproj rename libs/unimrcp/{libs/mrcp-client/mrcpclient.2012.vcxproj => tests/rtsptest/rtsptest.vcxproj} (51%) create mode 100644 libs/unimrcp/tests/rtsptest/rtsptest.vcxproj.filters delete mode 100644 libs/unimrcp/tests/strtablegen/strtablegen.2008.vcproj create mode 100644 libs/unimrcp/tests/strtablegen/strtablegen.vcxproj create mode 100644 libs/unimrcp/tests/strtablegen/strtablegen.vcxproj.filters create mode 100644 libs/unimrcp/unimrcp-2010.sln delete mode 100644 libs/unimrcp/unimrcp.2008.sln diff --git a/libs/.gitignore b/libs/.gitignore index 9876dac9aa..9da77e16e9 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -666,7 +666,7 @@ opal /unimrcp/build/svnrev/Makefile.in /unimrcp/build/svnrev/svnrev !/unimrcp/build/tools/unimrcpservice.exe.manifest -/unimrcp/build/uni_revision.h +!/unimrcp/build/uni_revision.h !/unimrcp/configure.gnu /unimrcp/conf/Makefile /unimrcp/conf/Makefile.in diff --git a/libs/apr/include/apr_ring.h b/libs/apr/include/apr_ring.h index eab1e69a84..a360254a38 100644 --- a/libs/apr/include/apr_ring.h +++ b/libs/apr/include/apr_ring.h @@ -377,6 +377,30 @@ #define APR_RING_REMOVE(ep, link) \ APR_RING_UNSPLICE((ep), (ep), link) +/** + * Iterate over a ring + * @param ep The current element + * @param head The head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_FOREACH(ep, head, elem, link) \ + for (ep = APR_RING_FIRST(head); \ + ep != APR_RING_SENTINEL(head, elem, link); \ + ep = APR_RING_NEXT(ep, link)) + +/** + * Iterate over a ring safe against removal of the current element + * @param ep1 The current element + * @param ep2 Iteration cursor + * @param head The head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_FOREACH_SAFE(ep1, ep2, head, elem, link) \ + for (ep1 = APR_RING_FIRST(head), ep2 = APR_RING_NEXT(ep1, link); \ + ep1 != APR_RING_SENTINEL(head, elem, link); \ + ep1 = ep2, ep2 = APR_RING_NEXT(ep1, link)) /* Debugging tools: */ diff --git a/libs/unimrcp/.update b/libs/unimrcp/.update index 05e080f0c9..5875d6e932 100644 --- a/libs/unimrcp/.update +++ b/libs/unimrcp/.update @@ -1 +1 @@ -Thu Jun 16 15:02:31 UTC 2011 +Mon Nov 17 11:06:30 EST 2014 diff --git a/libs/unimrcp/CHANGES b/libs/unimrcp/CHANGES new file mode 100644 index 0000000000..8271824144 --- /dev/null +++ b/libs/unimrcp/CHANGES @@ -0,0 +1,214 @@ +Changes for UniMRCP-1.2.0 + + APR-toolkit library + + * Implemented a new interface for the NLSML parser in accordance with the NSLML schema defined in http://tools.ietf.org/html/rfc6787#section-16.1. + * Took out the legacy NLSML interface. + * Fixed a gcc warning for strict-aliasing rules. + * Implemented apt_pair_array_generate() in 2 passes, apr_pstrcatv() alike. + * Prevent compilation warnings for unused-but-set-variable. + * Use int instead of apt_task_msg_type_e to suppress a warning triggered by gcc 4.7: case value not in enumerated type 'apt_task_msg_type_e'. + * Upon creation of a new memory pool, register apr_abortfunc_t callback which is supposed to be invoked when memory allocation fails within apr_pool. + * Added apt_va_log() which accepts va_list as an input argument. + * Set the default maximum number of log files used in rotation to 100. + * Set thread names for APT tasks to be shown in debuggers. Thanks Vali. + * Enable apt_timer logs only if APT_TIMER_DEBUG is defined. + * Use a local temporary char buffer to construct the hostname in apt_ip_get() not to allocate memory from a permanent pool. + * Unified pointer logging in APT style. Thanks Vali. + * Define APT_PTR_FMT as 0x%I64x for 64-bit Windows. + * Removed unused function apt_text_boolean_value_insert/apt_boolean_value_insert (inconsistent declaration/definition). Thanks Vali. + + MPF library + + * The function mpf_codec_lists_intersect() now returns FALSE if there is no match for the primary codec descriptor. + * Reject the RTP session if there is no match in remote and local codecs. + * Use the reserved RTP payload type 19 in case codec list is empty (media stream is rejected). + * If the codec list does not match the capabilities, mark the stream as disabled. + * Do not set SO_REUSEADDR on RTP sockets. + * Made G.711 implementation bit-exact with ITU-T reference implementation. + * Use APR typedefs in G.711 implementation. + * Improved the RTP port management for those cases when the specified RTP port range is not enough to handle concurrent MRCP sessions. + * Check the number of ports per engine to be even to ensure there is a room for a pair of RTP/RTCP ports. + * Added debugging capabilities to mpf_frame_buffer. + * Copy name string when adding to codec capabilities. Thanks Vali. + + MRCP common library + + * Use apr_snprintf() instead of sprintf() in mrcp_request_id_generate(). + * Get rid of local fixed-size char buffers and additional string copies. Instead, allocate buffers from memory pool and generate strings straight into the buffers. + + MRCP client library + + * Completed the implementation of the new API function to retrieve a SIP/RTSP response code received from the server (Issue-90). + * Fixed a potential crash of the client stack which could happen when the server unexpectedly closes the MRCPv2 connection while the client stack is processing an application request. + * Allow a pool/factory of signaling agents to be defined with the MRCPv1 and/or MRCPv2 profiles. + * Respond straight away with success to the session termination request if the session creation failed in the first place. + * Keep track of associations between RTP termination factories (pools of RTP ports) and media engines. + * Allow a pool/factory of media processing engines to be defined with the MRCPv1 and/or MRCPv2 profiles. + * Allow a pool/factory of MRCPv2 connection agents to be defined with the MRCPv2 profiles. + * Added the ability to specify an IP address by the name of network interface/adapter. + * Added a new accessor function to the client API mrcp_client_profiles_get() which retrieves the available profiles. + * Store the profile name not only as a key in the profile table but also in the profile structure. + * Allow setting an arbitrary tag to the profile. + + MRCP server library + + * Handle separately the case when an RTSP SETUP contains no SDP, which means it's up to the server to decide which codec to use. + * Fixed a crash if MRCP resource not found. Thanks Vali. + * Keep track of associations between RTP termination factories (pools of RTP ports) and media engines. + * Added the ability to specify an IP address by the name of network interface/adapter. + * Log maximum engine channel count exceeded. Thanks Vali. + + Sofia-SIP module (MRCPv2 agent) + + * Do not generate media format list for a disabled audio stream. + * Use snprintf() consistently in mrcp_sdp.c. + * Implemented the log redirection routine of SofiaSIP. + * Added an indentifier of the SofiaSIP agent to the log statement "Receive SIP Event". + + RTSP module (MRCPv1 agent) + + * Do not generate media format list for a disabled audio stream. + + Demo plugins + + * Respond with failure if codec descriptor is unavailable (associated media stream is disabled). + + UMC sample application + + * Terminate execution of sample application if media descriptor is unavailable (media stream is disabled). + * Use the new NLSML parser interface in sample apps. + * Set the header field Save-Waveform to TRUE in the sample umc recog application. + * Fixed an invalid read of 8 bytes in umc application: sizeof(mpf_codec_capabilities_t) was meant to be allocated. + + ASR Client application (and library) + + * Get rid of 1Kb grammar file limit in libasrclient. Load the content into an allocated buffer instead. + + Miscellaneous + + * Copy the version and revision header files located in the build directory to the SDK include directory. + * Added/fixed support for DESTDIR. + * Take into consideration m4 macro files generated for/by libtool 2. + * Set ac_macro_dir variable manually, since newer versions of autoconf don't do that. + * Enable silent build rules (--enable-silent-rules)and use silent build by default. + * Enhanced the report generated by the ./configure script. + * Pass no-define to AM_INIT_AUTOMAKE in order not to define PACKAGE and VERSION. + * Do not use autoconf generated compiler DEFS by replacing confdefs.h after AC_INIT, AM_INIT_AUTOMAKE and AC_PROG_LIBTOLL getting called. + * Updated definition of the macro AX_COMPILER_VENDOR and moved it out from configure.ac to a separate m4 file. + * Added missing dereferences of pointers to the (potential) terminal NUL of some strings. Thanks Vali. + * Disabled DEFAULT_INCLUDES provided by automake. + * Added generic apr_common.m4 in order to use helper m4 macros APR_ADDTO() and APR_CONFIG_NICE(). + * Generate ./config.nice to reuse ./configure command-line. + * Added uni_plugin.m4 which provides generic macros UNI_PLUGIN_ENABLED(name) and UNI_PLUGIN_DISABLED(name). + * Added common GNU make rules/vars for plugins, client and server libs/apps alike VS property sheets. + * The macro UNIMRCP_CHECK_APR() now checks and sets variables for both APR and APR-util libraries. + * Added a brief description of the license definition which is intended to be used for Windows resource files only. + * Brought XML schema definitions of configuration file formats up to date. + * Cppcheck: printf-like formats fix, possible NULL pointer dereference, member not initialized in the constructor, + unused variable/value, method can be made static. Thanks Vali. + * Define _WIN64 in Visual Studio x64 targets (for IDE only, the compiler defines _WIN64 anyway). Thanks Vali. + * Fixed some GCC warnings. Thanks Vali. + * Moved mrcp-flite and mrcp-pocketsphinx plugins out of the source tree into the external solutions directory. + + +Changes for UniMRCP-1.1.0 + + APR-toolkit library + + * The function apt_log_file_open() makes a copy of dir_path and file_name variables passed from a user application. + * Applied a patch to the apt_log routine which allows the log file to be appended instead of being overwritten. The patch was submitted by Dani. Thanks. + * Added a new parameter to the function apt_log_file_open() which specifies whether the log file should be appended or overwritten. + * Fixed the formatting of float values in the header fields. Applied a patch submitted by Randy (Issue-108). Thanks. + * Fixed apt_log_output_mode_check() which returned TRUE if any mode was enabled or checked regardless their correspondence. Thanks Vali. + * Enhanced the debug output by adding task message identifier to the log statements "Signal Message" and "Process Message". + * Fixed a potential crash related to the use of pollsets. + * Fixed a potential buffer overflow in apt_text_pair_array_insert(). Thanks Vali. + * Remove a socket descriptor from the pollset only if the descriptor has been properly added to the pollset. Otherwise, this operation could cause a crash. + + MPF library + + * Tweaked DTMF detector's energy thresholds to eliminate false positives during in-band (from audio) DTMF detection. Thanks Vali. + * Took into consideration the RTP marker in order to re-sync the jitter buffer on a new talkspurt. Audio data loss could be experienced in the RTP receiver in case of consecutive SPEAK (for client) or RECOGNIZE (for server) requests. + * Instead of discarding a non-aligned RTP packet, adjust the timestamp and write available frames to the jitter buffer (Issue-122). + * Added support for the adaptive jitter buffer. Applied a reworked patch submitted by Erik. Thanks. + * Enhanced the detection of a new RTP talkspurt by implicitly setting the RTP marker if a gap between two RTP packets is more than the specified threshold (INTER_TALSKPUSRT_GAP = 1000 msec). + * Allow the initial playout delay in the jitter buffer to be set to 0. + * Implemented a time skew detection algorithm for RTP streams. The detection can be enabled and used for both the adaptive and static jitter buffer. + * Added support for redirection of RTP traces (RTP_TRACE, JB_TRACE) to the debug output window of Visual Studio. + * Enhanced the processing of the RTP named events. + + RTSP library + + * Use strcasecmp() instead of apr_strnatcasecmp() to match RTSP resource names (Issue-94). + * Fixed a crash in the RTSP client stack when the server closes a TCP connection while the associated RTSP session is being destroyed (Issue-124). + * Fixed the processing of RTSP TEARDOWN requests being timed out. Applied a patch submitted to Issue-125 by Chris. Thanks. + * For logging purposes, pass a string identifier of the RTSP/MRCPv1 signaling agent to the RTSP client and server stacks. + + MRCP common library + + * Added missing recognizer header fields used for voice enrollment (speaker-dependent recognition). + * Added support for custom MRCP header fields. + * Added support for speaker verification and identification resource. + * Added missing recognizer methods used for voice enrollment and interpretation. + * Updated the state machine of the recognizer resource to take into consideration requests, responses and events used for interpretation. + * Enhanced helper functions which operate on the MRCP header to properly set, get and inherit header fields (Issue-110). + + MRCP client library + + * Added support for SIP redirection with 300 Multiple Choices used by the Nuance Resource Manager. + * Added support for feature-tags set in the SIP Accept-Contact header field in an outgoing SIP INVITE message sent to the Nuance Resource Manager. + * Added a new accessor function to the client API to get an audio stream associated with the specified channel. The function name is mrcp_application_audio_stream_get(). + * Added the ability to retrieve an external object associated with the MRCP session through the log handler (apt_log_ext_handler_f). + * Fixed the processing of a response to the SIP OPTIONS request used for resource discovery (Issue-112). + * Added a new constructor function unimrcp_client_create2() which allows to pass the client XML configuration not by a file, but rather by a string parameter. Thanks Vali. + * Fixed the processing of more than one pending application requests upon reception of a SIP BYE message from the server. + * Fixed the loading of the client configuration parameter . + * Respond to client user application requests with failure if a new session couldn't be created due to an error in initialization of the SIP stack (Issue-127). + * When originating an offer from the client, take into account capabilities of an audio stream created by the client user application. + * Added a new function to the client API to retrieve a SIP/RTSP response code received from the server (Issue-90). The support is incomplete. + + MRCP server library + + * Fixed an interoperability issue with AVP. The mid attribute is not required when the SDP contains only one m-line. + * Fixed the build of C++ MRCP plugins for platforms other than Win32. Thanks Vali. + * Added the ability to take and use parameters set by the plugin in a response to the GET-PARAMS request. Thanks Vali. + + Sofia-SIP module + + * Took out unused tags (variables) to compile with Sofia-SIP 1.12.11. + * Added support for Sofia-SIP's TPTAG_LOG() and TPTAG_DUMP() tags which can be enabled from the client and server configuration to print out and/or dump SIP messages. + + PocketSphinx plugin + + * In the PocketSphinx plugin, instead of using one common timeout for detection of speech activity and inactivity, use two different timeouts: one for activity and the other for inactivity detection. + * In the recognition results sent from the PocketSphinx plugin, set both and elements. + * Fixed a race condition in the PocketSphinx plugin which caused the server to crash. + * Fixed the use of recognition timer in the PocketSphinx plugin. + * Set an MRCP version specific completion cause in the PocketSphinx plugin. + + UniMRCP server application + + * Enhanced the UniMRCP Windows service manager. Thanks Vali. + * Corrected FileType in Windows resources from DLL to APP. Thanks Vali. + * Added a Windows resource file for the unimrcpservice application. + + UMC sample application + + * Set the default profile name in umcscenarios.xml to "uni2". + * Added sample 8kHz and 16 kHz voiceprints in the data directory which are used by the umc application for a sample verification scenario. + * Added mandatory attributes for the SSML element in the sample speak.xml file. + * Added support for a binary recognition grammar used in RecogScenario by the sample umc application. Thanks Vali. + * Added a sample SRGS ABNF grammar to the data directory. + + Miscellaneous + + * Added init.d script. The script was originally submitted by pdeschen. Thanks. + * Modified the "prepare" utility project to use the new location of PthreadVC2.dll which is now built from source with other dependencies. + * Added support for Visual Studio 2010. + * Modified the MPF test application to read a raw PCM data from one file, transmit it over RTP, and write the data back to another file. + * Set the libtool parameters link_all_deplibs and link_all_deplibs_CXX to "yes" by default, with an option to disable them (--disable-interlib-deps), if ever needed. This fixes a link error on recent Debian/Ubuntu distributions. + * Modified the apr.m4 and apu.m4 macros to use '--link-ld' instead of '--link-libtool --libs' for the APR library dependencies. This addresses the problem with a wrong -L path to the expat library. + * Set prerequisite version for autoconf to 2.59. + * Added a checking for pkg-config to the configure script. + * Added a new option (-v or --version) to the unimrcpserver as well as the sample umc and unimrcpclient applications. diff --git a/libs/unimrcp/INSTALL b/libs/unimrcp/INSTALL index b410e158ae..2d4f0d8eec 100644 --- a/libs/unimrcp/INSTALL +++ b/libs/unimrcp/INSTALL @@ -1,96 +1,117 @@ BUILD REQUIREMENTS ================== -UniMRCP depends on a number of third party tools and libraries, -which are required and must be installed first. -The easiest and recommended way is to install an appropriate -dependency package from the download area, which contains APR, -APR-Util and Sofia-SIP libraries prepackaged for UniMRCP use. +The UniMRCP project depends on a number of third party tools and libraries which must be installed first. -http://code.google.com/p/unimrcp/downloads/ +All the required dependencies are available to download prepackaged for the UniMRCP use from the +following location: -Alternatively, the original packages of APR, APR-Util and -Sofia-SIP libraries and patches for them can be downloaded from + http://www.unimrcp.org/downloads/dependencies -http://www.unimrcp.org/dependencies/ +Alternatively, original versions of the libraries as well as patches on them can be downloaded +separately from the following location: + + http://www.unimrcp.org/dependencies References: - -1. Apache Portable Runtime [>=1.2.x] (http://apr.apache.org/). -Whenever you want to build any part of UniMRCP, you need the -Apache Portable Runtime (APR) and the APR Utility (APR-util) -libraries. -2. Sofia-SIP [>=1.12.6] (http://sofia-sip.sourceforge.net/). -Sofia-SIP library is used to implement MRCPv2 specification -compliant SIP signaling. Sofia-SIP is an open-source SIP User-Agent -library, compliant with the IETF RFC3261 specification. +1. Apache Portable Runtime [>=1.2.x] (http://apr.apache.org). +In order to build any part of the UniMRCP project, the Apache Portable Runtime (APR) and +the APR Utility (APR-util) libraries are required. The libraries provide a consistent interface to +underlying platform-specific implementations. + +2. Sofia-SIP [>=1.12.6] (http://sofia-sip.sourceforge.net). +Sofia-SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification. +The library is utilized for implementation of SIP signaling for MRCPv2. The SDP message parser is +also used for both MRCPv2 (SIP/SDP) and MRCPv1 (RTSP/SDP). GNU BUILD -=================== -Additional requirements -- autoconf 2.57 or newer -- automake -- libtool 1.4 or newer -- gcc -- pkg-config +========= -Build procedure -$ ./bootstrap -$ ./configure -$ make -$ make install +Prerequisites: -Installed directory layout -bin - binaries (unimrcpserver, unimrcpclient) -conf - configuration files -data - data files -include - header files -lib - shared (convenient) libraries -log - log files -plugin - run-time loadable modules + autoconf 2.59 or newer + automake + libtool 1.4 or newer + gcc + pkg-config -There are a couple of options to "./configure". -To specify where to look for the APR and APR-util libraries -use the "--with-apr=" and "--with-apr-util=" options. -For example -$ ./configure --with-apr=/usr/local/apr \ - --with-apr-util=/usr/local/apr -To specify where to look for the Sofia-SIP library -use the "--with-sofia-sip=" option. -For example -$ ./configure --with-sofia-sip=/usr/local/sofia-sip +Procedure: -To cross-compile for 64-bit platform use -CFLAGS=-m64 CXXFLAGS=-m64 LDFLAGS=-m64 ./configure +If the UniMRCP source is checked out from the repository, the "bootstrap" script must be run first +in order to generate the "configure" script and other required files. -To cross-compile for 32-bit platform use -CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 ./configure + ./bootstrap -To install the default configuration use -$ cd conf -$ make def-conf +The usual "configure", "make", "make install" sequence of commands should follow in order to build +and install the project from source. -To install the default data use -$ cd data -$ make def-data + ./configure + make + make install -To generate doxygen documentation from the source use -$ make dox +As a result, the project will be installed in the directory "/usr/local/unimrcp" with the following +layout: + bin binaries (unimrcpserver, unimrcpclient, ...) + conf configuration files (unimrcpserver.xml, unimrcpclient.xml, ...) + data data files + include header files + lib shared (convenience) libraries + log log files + plugin run-time loadable modules + +There are a couple of options which can additionally be configured. +In order to specify where to look for the APR and APR-util libraries, use the "--with-apr=" and +"--with-apr-util=" options respectively. For example: + + ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr + +In order to specify where to look for the Sofia-SIP library, use the "--with-sofia-sip=" option. +For example: + + ./configure --with-sofia-sip=/usr/local/sofia-sip + +In order to generate executables and shared libraries for x86-64 architecture, use the "-m64" +option as follows: + + CFLAGS=-m64 CXXFLAGS=-m64 LDFLAGS=-m64 ./configure + +In order to generate executables and shared libraries for i386 architecture, use the "-m32" option +as follows: + + CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 ./configure + +In order to install the default configuration, use the following commands: + + cd conf + make def-conf + +In order to install the default data files, use the following commands: + + cd data + make def-data + +In order to build a Doxygen generated documentation, use the following command: + + make dox WINDOWS BUILD -====================== -Additional requirements -- Microsoft Visual Studio 2005 +============= -One-time pre-build preparation -You may need to adjust the paths for 3-rd party libraries -in appropriate property sheets to match your local installation, -while below are the defaults (build/vsprops). +Prerequisites: + + Microsoft Visual Studio 2005 or 2010. + +One-time pre-build setup: [optional] + +This step can be skipped if the dependencies are installed in their default locations. Otherwise, +the paths in the corresponding property sheets must be modified accordingly. Below is the content +of property sheets for Visual Studio 2005, which are located in the directory "build/vsprops". +Similarly, property sheets for Visual Studio 2010 can be found in the directory "build/props". apr.vsprops -Build procedure -- open unimrcp.sln solution file -- choose an appropriate solution platform (Build -> Configuration Manager) either win32 or x64 -- choose an appropriate solution configuration (Build -> Configuration Manager) either Debug or Release -- build the solution (Build -> Build Solution) +Procedure: -One-time pre-run output directory preparation -Build prepare.vcproj utility project (right click on tools -> prebuild in -Solution Explorer and select Build from context menu). This is a one-time -output directory preparation. It copies all the required APR and SofiaSIP -libraries and the default configuration to the output directory. +1. Open one of the available solution files: + * for Visual Studio 2005, use unimrcp.sln, + * for Visual Studio 2010, use unimrcp-2010.sln. +2. Choose a platform (Build -> Configuration Manager): + * win32 + * x64. +3. Choose a configuration (Build -> Configuration Manager): + * Debug + * Release. +4. Build the solution (Build -> Build Solution). -Output directory layout -bin - binaries (unimrcpserver, unimrcpclient) and all the required dlls -conf - configuration files -data - data files -lib - libraries -log - log files -plugin - run-time loadable modules +One-time output directory setup: + +Build the "prepare.vcproj" utility project by right clicking on the project icon from the Solution +Explorer (tools->prepare) and selecting the Build command from the context menu. This routine will +setup the output directory and copy all the required APR, APR-Util, and Sofia-SIP libraries as well +as the default configuration and data files. As a result, the output directory layout will look +like the following: + + bin binaries (unimrcpserver, unimrcpclient, ...) and all the required dlls + conf configuration files (unimrcpserver.xml, unimrcpclient.xml, ...) + data data files + lib libraries + log log files + plugin run-time loadable modules diff --git a/libs/unimrcp/Makefile.am b/libs/unimrcp/Makefile.am index 0719b6bf78..caa6756c06 100644 --- a/libs/unimrcp/Makefile.am +++ b/libs/unimrcp/Makefile.am @@ -1,26 +1,36 @@ -macrodir = @ac_macro_dir@ -auxdir = @ac_aux_dir@ -AUX_DIST = $(auxdir)/config.guess \ - $(auxdir)/config.sub \ - $(auxdir)/install-sh \ - $(auxdir)/ltconfig \ - $(auxdir)/ltmain.sh \ - $(auxdir)/depcomp \ - $(auxdir)/missing -EXTRA_DIST = bootstrap +macrodir = @ac_macro_dir@ +auxdir = @ac_aux_dir@ -AUTOMAKE_OPTIONS = foreign -MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure $(AUX_DIST) +AUX_DIST = $(auxdir)/compile \ + $(auxdir)/config.guess \ + $(auxdir)/config.sub \ + $(auxdir)/install-sh \ + $(auxdir)/ltconfig \ + $(auxdir)/ltmain.sh \ + $(auxdir)/depcomp \ + $(auxdir)/missing -ACLOCAL = aclocal +MACRO_DIST = $(macrodir)/libtool.m4 \ + $(macrodir)/ltoptions.m4 \ + $(macrodir)/ltsugar.m4 \ + $(macrodir)/ltversion.m4 \ + $(macrodir)/lt~obsolete.m4 -SUBDIRS = build conf data libs modules plugins platforms +EXTRA_DIST = bootstrap + +AUTOMAKE_OPTIONS = foreign +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.nice $(AUX_DIST) $(MACRO_DIST) + +ACLOCAL = aclocal -I $(macrodir) + +SUBDIRS = build conf data libs modules plugins platforms if TEST_SUITES -SUBDIRS += tests +SUBDIRS += tests endif dox: doxygen $(top_srcdir)/docs/doxygen.conf - + install-data-local: - test -d $(logdir) || $(mkinstalldirs) $(logdir) + test -d $(DESTDIR)$(logdir) || $(mkinstalldirs) $(DESTDIR)$(logdir) + test -d $(DESTDIR)$(vardir) || $(mkinstalldirs) $(DESTDIR)$(vardir) diff --git a/libs/unimrcp/README b/libs/unimrcp/README index 57834050a4..55e84045be 100644 --- a/libs/unimrcp/README +++ b/libs/unimrcp/README @@ -1,30 +1,37 @@ INTRODUCTION ============ -UniMRCP is an open source MRCP Project. + +UniMRCP is an open source project compliant with the IETF RFC6787 (MRCPv2) and RFC4463 (MRCPv1) +specifications. INSTALLATION ============ -See the file "INSTALLATION" for installation tips. + +See the file "INSTALL" for installation tips. DOCUMENTATION ============= -See the directory "docs/dox" for doxygen generated documentation. -See the directory "docs/ea" for UML based design concepts - (Enterpise Architect generated HTML pages). + +Use the directory "docs/dox" for a documentation generated by Doxygen. +Use the directory "docs/ea" for UML based design concepts, HTML pages generated by Enterpise Architect. REFERENCES ========== + Website: http://www.unimrcp.org -Project Home: - http://code.google.com/p/unimrcp +Downloads: + http://www.unimrcp.org/downloads -Wiki: - http://code.google.com/p/unimrcp/w/list +Documentation: + http://www.unimrcp.org/documentation + +Google Code: + http://code.google.com/p/unimrcp Issue Tracker: http://code.google.com/p/unimrcp/issues/list @@ -45,7 +52,8 @@ Commit Monitor: LICENSING ========= -UniMRCP is licensed under terms of the Apache 2.0 license. + +UniMRCP is licensed under terms of the Apache License 2.0. See the file "LICENSE" for more information. -Copyright 2008 - 2010 Arsen Chaloyan +Copyright 2008 - 2014 Arsen Chaloyan diff --git a/libs/unimrcp/acinclude.m4 b/libs/unimrcp/acinclude.m4 index 7a487f7046..14fa221614 100644 --- a/libs/unimrcp/acinclude.m4 +++ b/libs/unimrcp/acinclude.m4 @@ -1,8 +1,7 @@ m4_include([build/acmacros/apr.m4]) -m4_include([build/acmacros/apu.m4]) m4_include([build/acmacros/find_apr.m4]) m4_include([build/acmacros/find_apu.m4]) m4_include([build/acmacros/sofia-sip.m4]) -m4_include([build/acmacros/sphinxbase.m4]) -m4_include([build/acmacros/pocketsphinx.m4]) -m4_include([build/acmacros/flite.m4]) +m4_include([build/acmacros/ax_compiler_vendor.m4]) +m4_include([build/acmacros/apr_common.m4]) +m4_include([build/acmacros/uni_plugin.m4]) diff --git a/libs/unimrcp/build/Makefile.am b/libs/unimrcp/build/Makefile.am index 822c9173c8..859d2a553f 100644 --- a/libs/unimrcp/build/Makefile.am +++ b/libs/unimrcp/build/Makefile.am @@ -1,9 +1,5 @@ MAINTAINERCLEANFILES = Makefile.in -CLEANFILES = uni_revision.h -SUBDIRS = pkgconfig svnrev +SUBDIRS = pkgconfig include_HEADERS = uni_version.h uni_revision.h - -uni_revision.h : - svnrev/svnrev -rsvnrev/svnrev.input -p../ -ouni_revision.h diff --git a/libs/unimrcp/build/acmacros/apr.m4 b/libs/unimrcp/build/acmacros/apr.m4 index dc786c27e5..0fc55215eb 100644 --- a/libs/unimrcp/build/acmacros/apr.m4 +++ b/libs/unimrcp/build/acmacros/apr.m4 @@ -1,5 +1,9 @@ -dnl UNIMRCP_CHECK_APR - +dnl +dnl UNIMRCP_CHECK_APR +dnl +dnl This macro attempts to find APR and APR-util libraries and +dnl set corresponding variables on exit. +dnl AC_DEFUN([UNIMRCP_CHECK_APR], [ AC_MSG_NOTICE([Apache Portable Runtime (APR) library configuration]) @@ -16,18 +20,39 @@ AC_DEFUN([UNIMRCP_CHECK_APR], fi dnl check APR version number - apr_version="`$apr_config --version`" AC_MSG_RESULT([$apr_version]) dnl Get build information from APR + APR_ADDTO(CPPFLAGS,`$apr_config --cppflags`) + APR_ADDTO(CFLAGS,`$apr_config --cflags`) + APR_ADDTO(LDFLAGS,`$apr_config --ldflags`) - CPPFLAGS="$CPPFLAGS `$apr_config --cppflags`" - CFLAGS="$CFLAGS `$apr_config --cflags`" - LDFLAGS="$LDFLAGS `$apr_config --ldflags`" + APR_ADDTO(UNIMRCP_APR_INCLUDES,`$apr_config --includes`) + APR_ADDTO(UNIMRCP_APR_LIBS,`$apr_config --link-ld`) - UNIMRCP_APR_INCLUDES="`$apr_config --includes`" - UNIMRCP_APR_LIBS="`$apr_config --link-libtool --libs`" + AC_MSG_NOTICE([Apache Portable Runtime Utility (APU) library configuration]) + + APR_FIND_APU("", "", 1, 1) + + if test $apu_found = "no"; then + AC_MSG_WARN([APU not found]) + UNIMRCP_DOWNLOAD_APU + fi + + if test $apu_found = "reconfig"; then + AC_MSG_WARN([APU reconfig]) + fi + + dnl check APU version number + apu_version="`$apu_config --version`" + AC_MSG_RESULT([$apu_version]) + + dnl Get build information from APU + APR_ADDTO(LDFLAGS,`$apu_config --ldflags`) + + APR_ADDTO(UNIMRCP_APR_INCLUDES,`$apu_config --includes`) + APR_ADDTO(UNIMRCP_APR_LIBS,`$apu_config --link-ld`) AC_SUBST(UNIMRCP_APR_INCLUDES) AC_SUBST(UNIMRCP_APR_LIBS) @@ -42,3 +67,13 @@ AC_DEFUN([UNIMRCP_DOWNLOAD_APR], echo "--with-apr option to 'configure'" AC_MSG_ERROR([no suitable APR found]) ]) + +dnl UNIMRCP_DOWNLOAD_APU +dnl no apr-util found, print out a message telling the user what to do +AC_DEFUN([UNIMRCP_DOWNLOAD_APU], +[ + echo "The Apache Portable Runtime Utility (APU) library cannot be found." + echo "Please install APRUTIL on this system and supply the appropriate" + echo "--with-apr-util option to 'configure'" + AC_MSG_ERROR([no suitable APU found]) +]) diff --git a/libs/unimrcp/build/acmacros/apr_common.m4 b/libs/unimrcp/build/acmacros/apr_common.m4 new file mode 100644 index 0000000000..6b5c0f033b --- /dev/null +++ b/libs/unimrcp/build/acmacros/apr_common.m4 @@ -0,0 +1,990 @@ +dnl -------------------------------------------------------- -*- autoconf -*- +dnl Licensed to the Apache Software Foundation (ASF) under one or more +dnl contributor license agreements. See the NOTICE file distributed with +dnl this work for additional information regarding copyright ownership. +dnl The ASF licenses this file to You under the Apache License, Version 2.0 +dnl (the "License"); you may not use this file except in compliance with +dnl the License. You may obtain a copy of the License at +dnl +dnl http://www.apache.org/licenses/LICENSE-2.0 +dnl +dnl Unless required by applicable law or agreed to in writing, software +dnl distributed under the License is distributed on an "AS IS" BASIS, +dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +dnl See the License for the specific language governing permissions and +dnl limitations under the License. + +dnl +dnl apr_common.m4: APR's general-purpose autoconf macros +dnl + +dnl +dnl APR_CONFIG_NICE(filename) +dnl +dnl Saves a snapshot of the configure command-line for later reuse +dnl +AC_DEFUN([APR_CONFIG_NICE], [ + rm -f $1 + cat >$1<> $1 + fi + if test -n "$CFLAGS"; then + echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1 + fi + if test -n "$CPPFLAGS"; then + echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1 + fi + if test -n "$LDFLAGS"; then + echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1 + fi + if test -n "$LTFLAGS"; then + echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> $1 + fi + if test -n "$LIBS"; then + echo "LIBS=\"$LIBS\"; export LIBS" >> $1 + fi + if test -n "$INCLUDES"; then + echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1 + fi + if test -n "$NOTEST_CFLAGS"; then + echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1 + fi + if test -n "$NOTEST_CPPFLAGS"; then + echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1 + fi + if test -n "$NOTEST_LDFLAGS"; then + echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1 + fi + if test -n "$NOTEST_LIBS"; then + echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1 + fi + + # Retrieve command-line arguments. + eval "set x $[0] $ac_configure_args" + shift + + for arg + do + APR_EXPAND_VAR(arg, $arg) + echo "\"[$]arg\" \\" >> $1 + done + echo '"[$]@"' >> $1 + chmod +x $1 +])dnl + +dnl APR_MKDIR_P_CHECK(fallback-mkdir-p) +dnl checks whether mkdir -p works +AC_DEFUN([APR_MKDIR_P_CHECK], [ + AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[ + test -d conftestdir && rm -rf conftestdir + mkdir -p conftestdir/somedir >/dev/null 2>&1 + if test -d conftestdir/somedir; then + ac_cv_mkdir_p=yes + else + ac_cv_mkdir_p=no + fi + rm -rf conftestdir + ]) + if test "$ac_cv_mkdir_p" = "yes"; then + mkdir_p="mkdir -p" + else + mkdir_p="$1" + fi +]) + +dnl +dnl APR_SUBDIR_CONFIG(dir [, sub-package-cmdline-args, args-to-drop]) +dnl +dnl dir: directory to find configure in +dnl sub-package-cmdline-args: arguments to add to the invocation (optional) +dnl args-to-drop: arguments to drop from the invocation (optional) +dnl +dnl Note: This macro relies on ac_configure_args being set properly. +dnl +dnl The args-to-drop argument is shoved into a case statement, so +dnl multiple arguments can be separated with a |. +dnl +dnl Note: Older versions of autoconf do not single-quote args, while 2.54+ +dnl places quotes around every argument. So, if you want to drop the +dnl argument called --enable-layout, you must pass the third argument as: +dnl [--enable-layout=*|\'--enable-layout=*] +dnl +dnl Trying to optimize this is left as an exercise to the reader who wants +dnl to put up with more autoconf craziness. I give up. +dnl +AC_DEFUN([APR_SUBDIR_CONFIG], [ + # save our work to this point; this allows the sub-package to use it + AC_CACHE_SAVE + + echo "configuring package in $1 now" + ac_popdir=`pwd` + apr_config_subdirs="$1" + test -d $1 || $mkdir_p $1 + ac_abs_srcdir=`(cd $srcdir/$1 && pwd)` + cd $1 + +changequote(, )dnl + # A "../" for each directory in /$config_subdirs. + ac_dots=`echo $apr_config_subdirs|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'` +changequote([, ])dnl + + # Make the cache file pathname absolute for the subdirs + # required to correctly handle subdirs that might actually + # be symlinks + case "$cache_file" in + /*) # already absolute + ac_sub_cache_file=$cache_file ;; + *) # Was relative path. + ac_sub_cache_file="$ac_popdir/$cache_file" ;; + esac + + ifelse($3, [], [apr_configure_args=$ac_configure_args],[ + apr_configure_args= + apr_sep= + for apr_configure_arg in $ac_configure_args + do + case "$apr_configure_arg" in + $3) + continue ;; + esac + apr_configure_args="$apr_configure_args$apr_sep'$apr_configure_arg'" + apr_sep=" " + done + ]) + + dnl autoconf doesn't add --silent to ac_configure_args; explicitly pass it + test "x$silent" = "xyes" && apr_configure_args="$apr_configure_args --silent" + + dnl AC_CONFIG_SUBDIRS silences option warnings, emulate this for 2.62 + apr_configure_args="--disable-option-checking $apr_configure_args" + + dnl The eval makes quoting arguments work - specifically the second argument + dnl where the quoting mechanisms used is "" rather than []. + dnl + dnl We need to execute another shell because some autoconf/shell combinations + dnl will choke after doing repeated APR_SUBDIR_CONFIG()s. (Namely Solaris + dnl and autoconf-2.54+) + if eval $SHELL $ac_abs_srcdir/configure $apr_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_abs_srcdir $2 + then : + echo "$1 configured properly" + else + echo "configure failed for $1" + exit 1 + fi + + cd $ac_popdir + + # grab any updates from the sub-package + AC_CACHE_LOAD +])dnl + +dnl +dnl APR_SAVE_THE_ENVIRONMENT(variable_name) +dnl +dnl Stores the variable (usually a Makefile macro) for later restoration +dnl +AC_DEFUN([APR_SAVE_THE_ENVIRONMENT], [ + apr_ste_save_$1="$$1" +])dnl + +dnl +dnl APR_RESTORE_THE_ENVIRONMENT(variable_name, prefix_) +dnl +dnl Uses the previously saved variable content to figure out what configure +dnl has added to the variable, moving the new bits to prefix_variable_name +dnl and restoring the original variable contents. This makes it possible +dnl for a user to override configure when it does something stupid. +dnl +AC_DEFUN([APR_RESTORE_THE_ENVIRONMENT], [ +dnl Check whether $apr_ste_save_$1 is empty or +dnl only whitespace. The verbatim "X" is token number 1, +dnl the following whitespace will be ignored. +set X $apr_ste_save_$1 +if test ${#} -eq 1; then + $2$1="$$1" + $1= +else + if test "x$apr_ste_save_$1" = "x$$1"; then + $2$1= + else + $2$1=`echo "$$1" | sed -e "s%${apr_ste_save_$1}%%"` + $1="$apr_ste_save_$1" + fi +fi +if test "x$silent" != "xyes"; then + echo " restoring $1 to \"$$1\"" + echo " setting $2$1 to \"$$2$1\"" +fi +AC_SUBST($2$1) +])dnl + +dnl +dnl APR_SETIFNULL(variable, value) +dnl +dnl Set variable iff it's currently null +dnl +AC_DEFUN([APR_SETIFNULL], [ + if test -z "$$1"; then + test "x$silent" != "xyes" && echo " setting $1 to \"$2\"" + $1="$2" + fi +])dnl + +dnl +dnl APR_SETVAR(variable, value) +dnl +dnl Set variable no matter what +dnl +AC_DEFUN([APR_SETVAR], [ + test "x$silent" != "xyes" && echo " forcing $1 to \"$2\"" + $1="$2" +])dnl + +dnl +dnl APR_ADDTO(variable, value) +dnl +dnl Add value to variable +dnl +AC_DEFUN([APR_ADDTO], [ + if test "x$$1" = "x"; then + test "x$silent" != "xyes" && echo " setting $1 to \"$2\"" + $1="$2" + else + apr_addto_bugger="$2" + for i in $apr_addto_bugger; do + apr_addto_duplicate="0" + for j in $$1; do + if test "x$i" = "x$j"; then + apr_addto_duplicate="1" + break + fi + done + if test $apr_addto_duplicate = "0"; then + test "x$silent" != "xyes" && echo " adding \"$i\" to $1" + $1="$$1 $i" + fi + done + fi +])dnl + +dnl +dnl APR_REMOVEFROM(variable, value) +dnl +dnl Remove a value from a variable +dnl +AC_DEFUN([APR_REMOVEFROM], [ + if test "x$$1" = "x$2"; then + test "x$silent" != "xyes" && echo " nulling $1" + $1="" + else + apr_new_bugger="" + apr_removed=0 + for i in $$1; do + if test "x$i" != "x$2"; then + apr_new_bugger="$apr_new_bugger $i" + else + apr_removed=1 + fi + done + if test $apr_removed = "1"; then + test "x$silent" != "xyes" && echo " removed \"$2\" from $1" + $1=$apr_new_bugger + fi + fi +]) dnl + +dnl +dnl APR_CHECK_DEFINE_FILES( symbol, header_file [header_file ...] ) +dnl +AC_DEFUN([APR_CHECK_DEFINE_FILES], [ + AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[ + ac_cv_define_$1=no + for curhdr in $2 + do + AC_EGREP_CPP(YES_IS_DEFINED, [ +#include <$curhdr> +#ifdef $1 +YES_IS_DEFINED +#endif + ], ac_cv_define_$1=yes) + done + ]) + if test "$ac_cv_define_$1" = "yes"; then + AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined]) + fi +]) + + +dnl +dnl APR_CHECK_DEFINE(symbol, header_file) +dnl +AC_DEFUN([APR_CHECK_DEFINE], [ + AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[ + AC_EGREP_CPP(YES_IS_DEFINED, [ +#include <$2> +#ifdef $1 +YES_IS_DEFINED +#endif + ], ac_cv_define_$1=yes, ac_cv_define_$1=no) + ]) + if test "$ac_cv_define_$1" = "yes"; then + AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined in $2]) + fi +]) + +dnl +dnl APR_CHECK_APR_DEFINE( symbol ) +dnl +AC_DEFUN([APR_CHECK_APR_DEFINE], [ +apr_old_cppflags=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $INCLUDES" +AC_EGREP_CPP(YES_IS_DEFINED, [ +#include +#if $1 +YES_IS_DEFINED +#endif +], ac_cv_define_$1=yes, ac_cv_define_$1=no) +CPPFLAGS=$apr_old_cppflags +]) + +dnl APR_CHECK_FILE(filename); set ac_cv_file_filename to +dnl "yes" if 'filename' is readable, else "no". +dnl @deprecated! - use AC_CHECK_FILE instead +AC_DEFUN([APR_CHECK_FILE], [ +dnl Pick a safe variable name +define([apr_cvname], ac_cv_file_[]translit([$1], [./+-], [__p_])) +AC_CACHE_CHECK([for $1], [apr_cvname], +[if test -r $1; then + apr_cvname=yes + else + apr_cvname=no + fi]) +]) + +define(APR_IFALLYES,[dnl +ac_rc=yes +for ac_spec in $1; do + ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` + ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` + case $ac_type in + header ) + ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` + ac_var="ac_cv_header_$ac_item" + ;; + file ) + ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` + ac_var="ac_cv_file_$ac_item" + ;; + func ) ac_var="ac_cv_func_$ac_item" ;; + struct ) ac_var="ac_cv_struct_$ac_item" ;; + define ) ac_var="ac_cv_define_$ac_item" ;; + custom ) ac_var="$ac_item" ;; + esac + eval "ac_val=\$$ac_var" + if test ".$ac_val" != .yes; then + ac_rc=no + break + fi +done +if test ".$ac_rc" = .yes; then + : + $2 +else + : + $3 +fi +]) + + +define(APR_BEGIN_DECISION,[dnl +ac_decision_item='$1' +ac_decision_msg='FAILED' +ac_decision='' +]) + + +AC_DEFUN([APR_DECIDE],[dnl +dnl Define the flag (or not) in apr_private.h via autoheader +AH_TEMPLATE($1, [Define if $2 will be used]) +ac_decision='$1' +ac_decision_msg='$2' +ac_decision_$1=yes +ac_decision_$1_msg='$2' +]) + + +define(APR_DECISION_OVERRIDE,[dnl + ac_decision='' + for ac_item in $1; do + eval "ac_decision_this=\$ac_decision_${ac_item}" + if test ".$ac_decision_this" = .yes; then + ac_decision=$ac_item + eval "ac_decision_msg=\$ac_decision_${ac_item}_msg" + fi + done +]) + + +define(APR_DECISION_FORCE,[dnl +ac_decision="$1" +eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\"" +]) + + +define(APR_END_DECISION,[dnl +if test ".$ac_decision" = .; then + echo "[$]0:Error: decision on $ac_decision_item failed" 1>&2 + exit 1 +else + if test ".$ac_decision_msg" = .; then + ac_decision_msg="$ac_decision" + fi + AC_DEFINE_UNQUOTED(${ac_decision_item}) + AC_MSG_RESULT([decision on $ac_decision_item... $ac_decision_msg]) +fi +]) + + +dnl +dnl APR_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE]) +dnl +dnl A variant of AC_CHECK_SIZEOF which allows the checking of +dnl sizes of non-builtin types +dnl +AC_DEFUN([APR_CHECK_SIZEOF_EXTENDED], +[changequote(<<, >>)dnl +dnl The name to #define. +define(<>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl +dnl The cache variable name. +define(<>, translit(ac_cv_sizeof_$2, [ *], [_p]))dnl +changequote([, ])dnl +AC_MSG_CHECKING(size of $2) +AC_CACHE_VAL(AC_CV_NAME, +[AC_TRY_RUN([#include +$1 +#ifdef WIN32 +#define binmode "b" +#else +#define binmode +#endif +main() +{ + FILE *f=fopen("conftestval", "w" binmode); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof($2)); + exit(0); +}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,, +AC_CV_NAME=$3))])dnl +AC_MSG_RESULT($AC_CV_NAME) +AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The size of ]$2) +undefine([AC_TYPE_NAME])dnl +undefine([AC_CV_NAME])dnl +]) + + +dnl +dnl APR_TRY_COMPILE_NO_WARNING(INCLUDES, FUNCTION-BODY, +dnl [ACTIONS-IF-NO-WARNINGS], [ACTIONS-IF-WARNINGS]) +dnl +dnl Tries a compile test with warnings activated so that the result +dnl is false if the code doesn't compile cleanly. For compilers +dnl where it is not known how to activate a "fail-on-error" mode, +dnl it is undefined which of the sets of actions will be run. +dnl +AC_DEFUN([APR_TRY_COMPILE_NO_WARNING], +[apr_save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $CFLAGS_WARN" + if test "$ac_cv_prog_gcc" = "yes"; then + CFLAGS="$CFLAGS -Werror" + fi + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [#include "confdefs.h" + ] + [[$1]] + [int main(int argc, const char *const *argv) {] + [[$2]] + [ return 0; }] + )], + [$3], [$4]) + CFLAGS=$apr_save_CFLAGS +]) + +dnl +dnl APR_CHECK_STRERROR_R_RC +dnl +dnl Decide which style of retcode is used by this system's +dnl strerror_r(). It either returns int (0 for success, -1 +dnl for failure), or it returns a pointer to the error +dnl string. +dnl +dnl +AC_DEFUN([APR_CHECK_STRERROR_R_RC], [ +AC_MSG_CHECKING(for type of return code from strerror_r) +AC_TRY_RUN([ +#include +#include +#include +main() +{ + char buf[1024]; + if (strerror_r(ERANGE, buf, sizeof buf) < 1) { + exit(0); + } + else { + exit(1); + } +}], [ + ac_cv_strerror_r_rc_int=yes ], [ + ac_cv_strerror_r_rc_int=no ], [ + ac_cv_strerror_r_rc_int=no ] ) +if test "x$ac_cv_strerror_r_rc_int" = xyes; then + AC_DEFINE(STRERROR_R_RC_INT, 1, [Define if strerror returns int]) + msg="int" +else + msg="pointer" +fi +AC_MSG_RESULT([$msg]) +] ) + +dnl +dnl APR_CHECK_DIRENT_INODE +dnl +dnl Decide if d_fileno or d_ino are available in the dirent +dnl structure on this platform. Single UNIX Spec says d_ino, +dnl BSD uses d_fileno. Undef to find the real beast. +dnl +AC_DEFUN([APR_CHECK_DIRENT_INODE], [ +AC_CACHE_CHECK([for inode member of struct dirent], apr_cv_dirent_inode, [ +apr_cv_dirent_inode=no +AC_TRY_COMPILE([ +#include +#include +],[ +#ifdef d_ino +#undef d_ino +#endif +struct dirent de; de.d_fileno; +], apr_cv_dirent_inode=d_fileno) +if test "$apr_cv_dirent_inode" = "no"; then +AC_TRY_COMPILE([ +#include +#include +],[ +#ifdef d_fileno +#undef d_fileno +#endif +struct dirent de; de.d_ino; +], apr_cv_dirent_inode=d_ino) +fi +]) +if test "$apr_cv_dirent_inode" != "no"; then + AC_DEFINE_UNQUOTED(DIRENT_INODE, $apr_cv_dirent_inode, + [Define if struct dirent has an inode member]) +fi +]) + +dnl +dnl APR_CHECK_DIRENT_TYPE +dnl +dnl Decide if d_type is available in the dirent structure +dnl on this platform. Not part of the Single UNIX Spec. +dnl Note that this is worthless without DT_xxx macros, so +dnl look for one while we are at it. +dnl +AC_DEFUN([APR_CHECK_DIRENT_TYPE], [ +AC_CACHE_CHECK([for file type member of struct dirent], apr_cv_dirent_type,[ +apr_cv_dirent_type=no +AC_TRY_COMPILE([ +#include +#include +],[ +struct dirent de; de.d_type = DT_REG; +], apr_cv_dirent_type=d_type) +]) +if test "$apr_cv_dirent_type" != "no"; then + AC_DEFINE_UNQUOTED(DIRENT_TYPE, $apr_cv_dirent_type, + [Define if struct dirent has a d_type member]) +fi +]) + +dnl the following is a newline, a space, a tab, and a backslash (the +dnl backslash is used by the shell to skip newlines, but m4 sees it; +dnl treat it like whitespace). +dnl WARNING: don't reindent these lines, or the space/tab will be lost! +define([apr_whitespace],[ + \]) + +dnl +dnl APR_COMMA_ARGS(ARG1 ...) +dnl convert the whitespace-separated arguments into comman-separated +dnl arguments. +dnl +dnl APR_FOREACH(CODE-BLOCK, ARG1, ARG2, ...) +dnl subsitute CODE-BLOCK for each ARG[i]. "eachval" will be set to ARG[i] +dnl within each iteration. +dnl +changequote({,}) +define({APR_COMMA_ARGS},{patsubst([$}{1],[[}apr_whitespace{]+],[,])}) +define({APR_FOREACH}, + {ifelse($}{2,,, + [define([eachval], + $}{2)$}{1[]APR_FOREACH([$}{1], + builtin([shift], + builtin([shift], $}{@)))])}) +changequote([,]) + +dnl APR_FLAG_HEADERS(HEADER-FILE ... [, FLAG-TO-SET ] [, "yes" ]) +dnl we set FLAG-TO-SET to 1 if we find HEADER-FILE, otherwise we set to 0 +dnl if FLAG-TO-SET is null, we automagically determine it's name +dnl by changing all "/" to "_" in the HEADER-FILE and dropping +dnl all "." and "-" chars. If the 3rd parameter is "yes" then instead of +dnl setting to 1 or 0, we set FLAG-TO-SET to yes or no. +dnl +AC_DEFUN([APR_FLAG_HEADERS], [ +AC_CHECK_HEADERS($1) +for aprt_i in $1 +do + ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'` + aprt_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'` + if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,yes,1)" + else + eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,no,0)" + fi +done +]) + +dnl APR_FLAG_FUNCS(FUNC ... [, FLAG-TO-SET] [, "yes" ]) +dnl if FLAG-TO-SET is null, we automagically determine it's name +dnl prepending "have_" to the function name in FUNC, otherwise +dnl we use what's provided as FLAG-TO-SET. If the 3rd parameter +dnl is "yes" then instead of setting to 1 or 0, we set FLAG-TO-SET +dnl to yes or no. +dnl +AC_DEFUN([APR_FLAG_FUNCS], [ +AC_CHECK_FUNCS($1) +for aprt_j in $1 +do + aprt_3="have_$aprt_j" + if eval "test \"`echo '$ac_cv_func_'$aprt_j`\" = yes"; then + eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,yes,1)" + else + eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,no,0)" + fi +done +]) + +dnl Iteratively interpolate the contents of the second argument +dnl until interpolation offers no new result. Then assign the +dnl final result to $1. +dnl +dnl Example: +dnl +dnl foo=1 +dnl bar='${foo}/2' +dnl baz='${bar}/3' +dnl APR_EXPAND_VAR(fraz, $baz) +dnl $fraz is now "1/2/3" +dnl +AC_DEFUN([APR_EXPAND_VAR], [ +ap_last= +ap_cur="$2" +while test "x${ap_cur}" != "x${ap_last}"; +do + ap_last="${ap_cur}" + ap_cur=`eval "echo ${ap_cur}"` +done +$1="${ap_cur}" +]) + +dnl +dnl Removes the value of $3 from the string in $2, strips of any leading +dnl slashes, and returns the value in $1. +dnl +dnl Example: +dnl orig_path="${prefix}/bar" +dnl APR_PATH_RELATIVE(final_path, $orig_path, $prefix) +dnl $final_path now contains "bar" +AC_DEFUN([APR_PATH_RELATIVE], [ +ap_stripped=`echo $2 | sed -e "s#^$3##"` +# check if the stripping was successful +if test "x$2" != "x${ap_stripped}"; then + # it was, so strip of any leading slashes + $1="`echo ${ap_stripped} | sed -e 's#^/*##'`" +else + # it wasn't so return the original + $1="$2" +fi +]) + +dnl APR_HELP_STRING(LHS, RHS) +dnl Autoconf 2.50 can not handle substr correctly. It does have +dnl AC_HELP_STRING, so let's try to call it if we can. +dnl Note: this define must be on one line so that it can be properly returned +dnl as the help string. When using this macro with a multi-line RHS, ensure +dnl that you surround the macro invocation with []s +AC_DEFUN([APR_HELP_STRING], [ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING([$1],[$2]),[ ][$1] substr([ ],len($1))[$2])]) + +dnl +dnl APR_LAYOUT(configlayout, layoutname [, extravars]) +dnl +AC_DEFUN([APR_LAYOUT], [ + if test ! -f $srcdir/config.layout; then + echo "** Error: Layout file $srcdir/config.layout not found" + echo "** Error: Cannot use undefined layout '$LAYOUT'" + exit 1 + fi + # Catch layout names including a slash which will otherwise + # confuse the heck out of the sed script. + case $2 in + */*) + echo "** Error: $2 is not a valid layout name" + exit 1 ;; + esac + pldconf=./config.pld + changequote({,}) + sed -e "1s/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*//;1t" \ + -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \ + -e '/[ ]*<\/Layout>[ ]*/,$d' \ + -e "s/^[ ]*//g" \ + -e "s/:[ ]*/=\'/g" \ + -e "s/[ ]*$/'/g" \ + $1 > $pldconf + layout_name=$2 + if test ! -s $pldconf; then + echo "** Error: unable to find layout $layout_name" + exit 1 + fi + . $pldconf + rm $pldconf + for var in prefix exec_prefix bindir sbindir libexecdir mandir \ + sysconfdir datadir includedir localstatedir runtimedir \ + logfiledir libdir installbuilddir libsuffix $3; do + eval "val=\"\$$var\"" + case $val in + *+) + val=`echo $val | sed -e 's;\+$;;'` + eval "$var=\"\$val\"" + autosuffix=yes + ;; + *) + autosuffix=no + ;; + esac + val=`echo $val | sed -e 's:\(.\)/*$:\1:'` + val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'` + if test "$autosuffix" = "yes"; then + if echo $val | grep apache >/dev/null; then + addtarget=no + else + addtarget=yes + fi + if test "$addtarget" = "yes"; then + val="$val/apache2" + fi + fi + eval "$var='$val'" + done + changequote([,]) +])dnl + +dnl +dnl APR_ENABLE_LAYOUT(default layout name [, extra vars]) +dnl +AC_DEFUN([APR_ENABLE_LAYOUT], [ +AC_ARG_ENABLE(layout, +[ --enable-layout=LAYOUT],[ + LAYOUT=$enableval +]) + +if test -z "$LAYOUT"; then + LAYOUT="$1" +fi +APR_LAYOUT($srcdir/config.layout, $LAYOUT, $2) + +AC_MSG_CHECKING(for chosen layout) +AC_MSG_RESULT($layout_name) +]) + + +dnl +dnl APR_PARSE_ARGUMENTS +dnl a reimplementation of autoconf's argument parser, +dnl used here to allow us to co-exist layouts and argument based +dnl set ups. +AC_DEFUN([APR_PARSE_ARGUMENTS], [ +ac_prev= +# Retrieve the command-line arguments. The eval is needed because +# the arguments are quoted to preserve accuracy. +eval "set x $ac_configure_args" +shift +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[[^=]]*=\(.*\)'` + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + esac +done + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [[\\/$]]* | ?:[[\\/]]* | NONE | '' ) ;; + *) AC_MSG_ERROR([expected an absolute path for --$ac_var: $ac_val]);; + esac +done + +])dnl + +dnl +dnl APR_CHECK_DEPEND +dnl +dnl Determine what program we can use to generate .deps-style dependencies +dnl +AC_DEFUN([APR_CHECK_DEPEND], [ +dnl Try to determine what depend program we can use +dnl All GCC-variants should have -MM. +dnl If not, then we can check on those, too. +if test "$GCC" = "yes"; then + MKDEP='$(CC) -MM' +else + rm -f conftest.c +dnl should be available everywhere! + cat > conftest.c < + int main() { return 0; } +EOF + MKDEP="true" + for i in "$CC -MM" "$CC -M" "$CPP -MM" "$CPP -M" "cpp -M"; do + AC_MSG_CHECKING([if $i can create proper make dependencies]) + if $i conftest.c 2>/dev/null | grep 'conftest.o: conftest.c' >/dev/null; then + MKDEP=$i + AC_MSG_RESULT(yes) + break; + fi + AC_MSG_RESULT(no) + done + rm -f conftest.c +fi + +AC_SUBST(MKDEP) +]) + +dnl +dnl APR_CHECK_TYPES_COMPATIBLE(TYPE-1, TYPE-2, [ACTION-IF-TRUE]) +dnl +dnl Try to determine whether two types are the same. Only works +dnl for gcc and icc. +dnl +AC_DEFUN([APR_CHECK_TYPES_COMPATIBLE], [ +define([apr_cvname], apr_cv_typematch_[]translit([$1], [ ], [_])_[]translit([$2], [ ], [_])) +AC_CACHE_CHECK([whether $1 and $2 are the same], apr_cvname, [ +AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [ + int foo[0 - !__builtin_types_compatible_p($1, $2)]; +], [apr_cvname=yes +$3], [apr_cvname=no])]) +]) diff --git a/libs/unimrcp/build/acmacros/apu.m4 b/libs/unimrcp/build/acmacros/apu.m4 index 4d47f095f6..0399751157 100644 --- a/libs/unimrcp/build/acmacros/apu.m4 +++ b/libs/unimrcp/build/acmacros/apu.m4 @@ -1,42 +1,2 @@ -dnl UNIMRCP_CHECK_APU - -AC_DEFUN([UNIMRCP_CHECK_APU], -[ - AC_MSG_NOTICE([Apache Portable Runtime Utility (APU) library configuration]) - - APR_FIND_APU("", "", 1, 1) - - if test $apu_found = "no"; then - AC_MSG_WARN([APU not found]) - UNIMRCP_DOWNLOAD_APU - fi - - if test $apu_found = "reconfig"; then - AC_MSG_WARN([APU reconfig]) - fi - - dnl check APU version number - - apu_version="`$apu_config --version`" - AC_MSG_RESULT([$apu_version]) - - dnl Get build information from APU - - LDFLAGS="$LDFLAGS `$apu_config --ldflags`" - - UNIMRCP_APU_INCLUDES="`$apu_config --includes`" - UNIMRCP_APU_LIBS="`$apu_config --link-libtool --libs`" - - AC_SUBST(UNIMRCP_APU_INCLUDES) - AC_SUBST(UNIMRCP_APU_LIBS) -]) - -dnl UNIMRCP_DOWNLOAD_APU -dnl no apr-util found, print out a message telling the user what to do -AC_DEFUN([UNIMRCP_DOWNLOAD_APU], -[ - echo "The Apache Portable Runtime Utility (APU) library cannot be found." - echo "Please install APRUTIL on this system and supply the appropriate" - echo "--with-apr-util option to 'configure'" - AC_MSG_ERROR([no suitable APU found]) -]) +dnl The macro UNIMRCP_CHECK_APU() has been merged with the macro UNIMRCP_CHECK_APR(). +dnl This file is no longer used and pending for removal. diff --git a/libs/unimrcp/build/acmacros/ax_compiler_vendor.m4 b/libs/unimrcp/build/acmacros/ax_compiler_vendor.m4 new file mode 100644 index 0000000000..2f8d080249 --- /dev/null +++ b/libs/unimrcp/build/acmacros/ax_compiler_vendor.m4 @@ -0,0 +1,41 @@ +dnl Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, +dnl hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, +dnl watcom, etc. The vendor is returned in the cache variable +dnl $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. + +AC_DEFUN([AX_COMPILER_VENDOR], +[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, + [dnl note: don't check for gcc first since some other compilers define __GNUC__ + vendors="intel: __ICC,__ECC,__INTEL_COMPILER + ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ + pathscale: __PATHCC__,__PATHSCALE__ + clang: __clang__ + gnu: __GNUC__ + sun: __SUNPRO_C,__SUNPRO_CC + hp: __HP_cc,__HP_aCC + dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER + borland: __BORLANDC__,__TURBOC__ + comeau: __COMO__ + cray: _CRAYC + kai: __KCC + lcc: __LCC__ + sgi: __sgi,sgi + microsoft: _MSC_VER + metrowerks: __MWERKS__ + watcom: __WATCOMC__ + portland: __PGI + unknown: UNKNOWN" + for ventest in $vendors; do + case $ventest in + *:) vendor=$ventest; continue ;; + *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; + esac + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ + #if !($vencpp) + thisisanerror; + #endif + ])], [break]) + done + ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` + ]) +]) diff --git a/libs/unimrcp/build/acmacros/flite.m4 b/libs/unimrcp/build/acmacros/flite.m4 deleted file mode 100644 index 5585e963b4..0000000000 --- a/libs/unimrcp/build/acmacros/flite.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl UNIMRCP_CHECK_FLITE - -AC_DEFUN([UNIMRCP_CHECK_FLITE], -[ - AC_MSG_NOTICE([Flite library configuration]) - - AC_MSG_CHECKING([for Flite]) - AC_ARG_WITH(flite, - [ --with-flite=PATH path to Flite build tree], - [flite_path=$withval], - [flite_path="/usr/src/flite"] - ) - - found_flite="no" - - flite_config="config/config" - for dir in $flite_path ; do - cd $dir && flite_dir=`pwd` && cd - > /dev/null - if test -f "$flite_dir/$flite_config"; then - target_os=`grep TARGET_OS "$flite_dir/$flite_config" | sed "s/^.*= //"` ;\ - target_cpu=`grep TARGET_CPU "$flite_dir/$flite_config" | sed "s/^.*= //"` ;\ - flite_libdir=$flite_dir/build/$target_cpu-$target_os/lib - if test -d "$flite_libdir"; then - UNIMRCP_FLITE_INCLUDES="-I$flite_dir/include" - UNIMRCP_FLITE_LIBS="$flite_libdir/libflite_cmu_us_awb.a \ - $flite_libdir/libflite_cmu_us_kal.a \ - $flite_libdir/libflite_cmu_us_rms.a \ - $flite_libdir/libflite_cmu_us_slt.a \ - $flite_libdir/libflite_cmulex.a \ - $flite_libdir/libflite_usenglish.a \ - $flite_libdir/libflite.a" - found_flite="yes" - break - else - AC_MSG_WARN(Cannot find Flite lib dir: $flite_libdir) - fi - fi - done - - if test x_$found_flite != x_yes; then - AC_MSG_ERROR(Cannot find Flite - looked for srcdir:$flite_srcdir in $flite_path) - else - AC_MSG_RESULT([$found_flite]) - -case "$host" in - *darwin*) - UNIMRCP_FLITE_LIBS="$UNIMRCP_FLITE_LIBS -framework CoreFoundation -framework SystemConfiguration" ;; -esac - - AC_SUBST(UNIMRCP_FLITE_INCLUDES) - AC_SUBST(UNIMRCP_FLITE_LIBS) - fi -]) diff --git a/libs/unimrcp/build/acmacros/pocketsphinx.m4 b/libs/unimrcp/build/acmacros/pocketsphinx.m4 deleted file mode 100644 index 8f1eadcebe..0000000000 --- a/libs/unimrcp/build/acmacros/pocketsphinx.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl UNIMRCP_CHECK_POCKETSPHINX - -AC_DEFUN([UNIMRCP_CHECK_POCKETSPHINX], -[ - AC_MSG_NOTICE([PocketSphinx library configuration]) - - AC_MSG_CHECKING([for PocketSphinx]) - AC_ARG_WITH(pocketsphinx, - [ --with-pocketsphinx=PATH prefix for installed PocketSphinx or - path to PocketSphinx build tree], - [pocketsphinx_path=$withval], - [pocketsphinx_path="/usr/local"] - ) - - found_pocketsphinx="no" - pocketsphinx_config="lib/pkgconfig/pocketsphinx.pc" - pocketsphinx_srcdir="src" - for dir in $pocketsphinx_path ; do - cd $dir && pocketsphinx_dir=`pwd` && cd - > /dev/null - if test -f "$dir/$pocketsphinx_config"; then - found_pocketsphinx="yes" - UNIMRCP_POCKETSPHINX_INCLUDES="`pkg-config --cflags $dir/$pocketsphinx_config`" - UNIMRCP_POCKETSPHINX_LIBS="`pkg-config --libs $dir/$pocketsphinx_config`" - UNIMRCP_POCKETSPHINX_MODELS= - pocketsphinx_version="`pkg-config --modversion $dir/$pocketsphinx_config`" - break - fi - if test -d "$dir/$pocketsphinx_srcdir"; then - found_pocketsphinx="yes" - UNIMRCP_POCKETSPHINX_INCLUDES="-I$pocketsphinx_dir/include" - UNIMRCP_POCKETSPHINX_LIBS="$pocketsphinx_dir/$pocketsphinx_srcdir/libpocketsphinx/libpocketsphinx.la" - UNIMRCP_POCKETSPHINX_MODELS="$pocketsphinx_dir/model" - pocketsphinx_version="`pkg-config --modversion $pocketsphinx_dir/pocketsphinx.pc`" - break - fi - done - - if test x_$found_pocketsphinx != x_yes; then - AC_MSG_ERROR(Cannot find PocketSphinx - looked for pocketsphinx-config:$pocketsphinx_config and srcdir:$pocketsphinx_srcdir in $pocketsphinx_path) - else - AC_MSG_RESULT([$found_pocketsphinx]) - AC_MSG_RESULT([$pocketsphinx_version]) - -case "$host" in - *darwin*) - UNIMRCP_POCKETSPHINX_LIBS="$UNIMRCP_POCKETSPHINX_LIBS -framework CoreFoundation -framework SystemConfiguration" ;; -esac - - AC_SUBST(UNIMRCP_POCKETSPHINX_INCLUDES) - AC_SUBST(UNIMRCP_POCKETSPHINX_LIBS) - AC_SUBST(UNIMRCP_POCKETSPHINX_MODELS) - fi -]) diff --git a/libs/unimrcp/build/acmacros/sofia-sip.m4 b/libs/unimrcp/build/acmacros/sofia-sip.m4 index 95d6f50262..a8ee444e13 100644 --- a/libs/unimrcp/build/acmacros/sofia-sip.m4 +++ b/libs/unimrcp/build/acmacros/sofia-sip.m4 @@ -1,48 +1,75 @@ +dnl dnl UNIMRCP_CHECK_SOFIA - +dnl +dnl This macro attempts to find the Sofia-SIP library and +dnl set corresponding variables on exit. +dnl AC_DEFUN([UNIMRCP_CHECK_SOFIA], -[ +[ AC_MSG_NOTICE([Sofia SIP library configuration]) AC_MSG_CHECKING([for Sofia-SIP]) AC_ARG_WITH(sofia-sip, - [ --with-sofia-sip=PATH prefix for installed Sofia-SIP or - path to Sofia-SIP build tree], + [ --with-sofia-sip=PATH prefix for installed Sofia-SIP, + path to Sofia-SIP source/build tree, + or the full path to Sofia-SIP pkg-config], [sofia_path=$withval], [sofia_path="/usr/local"] ) - - found_sofia="no" - sofiaconfig="lib/pkgconfig/sofia-sip-ua.pc" - sofiasrcdir="libsofia-sip-ua" - for dir in $sofia_path ; do - cd $dir && sofiadir=`pwd` && cd - > /dev/null - sofiadirsrc=`(cd $srcdir/$dir && pwd)` - if test -f "$dir/$sofiaconfig"; then - found_sofia="yes" - UNIMRCP_SOFIA_INCLUDES="`pkg-config --cflags $dir/$sofiaconfig`" - UNIMRCP_SOFIA_LIBS="`pkg-config --libs $dir/$sofiaconfig`" - sofia_version="`pkg-config --modversion $dir/$sofiaconfig`" - break - fi - if test -d "$dir/$sofiasrcdir"; then - found_sofia="yes" - UNIMRCP_SOFIA_INCLUDES="-I$sofiadir/$sofiasrcdir -I$sofiadir/$sofiasrcdir/bnf -I$sofiadir/$sofiasrcdir/features -I$sofiadir/$sofiasrcdir/http -I$sofiadir/$sofiasrcdir/ipt -I$sofiadir/$sofiasrcdir/iptsec -I$sofiadir/$sofiasrcdir/msg -I$sofiadir/$sofiasrcdir/nea -I$sofiadir/$sofiasrcdir/nta -I$sofiadir/$sofiasrcdir/nth -I$sofiadir/$sofiasrcdir/nua -I$sofiadir/$sofiasrcdir/sdp -I$sofiadir/$sofiasrcdir/sip -I$sofiadir/$sofiasrcdir/soa -I$sofiadir/$sofiasrcdir/sresolv -I$sofiadir/$sofiasrcdir/stun -I$sofiadir/$sofiasrcdir/su -I$sofiadir/$sofiasrcdir/tport -I$sofiadir/$sofiasrcdir/url -I$sofiadirsrc/$sofiasrcdir -I$sofiadirsrc/$sofiasrcdir/bnf -I$sofiadirsrc/$sofiasrcdir/features -I$sofiadirsrc/$sofiasrcdir/http -I$sofiadirsrc/$sofiasrcdir/ipt -I$sofiadirsrc/$sofiasrcdir/iptsec -I$sofiadirsrc/$sofiasrcdir/msg -I$sofiadirsrc/$sofiasrcdir/nea -I$sofiadirsrc/$sofiasrcdir/nta -I$sofiadirsrc/$sofiasrcdir/nth -I$sofiadirsrc/$sofiasrcdir/nua -I$sofiadirsrc/$sofiasrcdir/sdp -I$sofiadirsrc/$sofiasrcdir/sip -I$sofiadirsrc/$sofiasrcdir/soa -I$sofiadirsrc/$sofiasrcdir/sresolv -I$sofiadirsrc/$sofiasrcdir/stun -I$sofiadirsrc/$sofiasrcdir/su -I$sofiadirsrc/$sofiasrcdir/tport -I$sofiadirsrc/$sofiasrcdir/url" - UNIMRCP_SOFIA_LIBS="$sofiadir/$sofiasrcdir/libsofia-sip-ua.la" - sofia_version="`pkg-config --modversion $sofiadir/packages/sofia-sip-ua.pc`" - break - fi - done - if test x_$found_sofia != x_yes; then - AC_MSG_ERROR(Cannot find Sofia-SIP - looked for sofia-config:$sofiaconfig and srcdir:$sofiasrcdir in $sofia_path) + found_sofia="no" + + if test -n "$PKG_CONFIG"; then + dnl Check for installed Sofia-SIP + for dir in $sofia_path ; do + sofia_config_path=$dir/lib/pkgconfig/sofia-sip-ua.pc + if test -f "$sofia_config_path" && $PKG_CONFIG $sofia_config_path > /dev/null 2>&1; then + found_sofia="yes" + break + fi + done + + dnl Check for full path to Sofia-SIP pkg-config file + if test "$found_sofia" != "yes" && test -f "$sofia_path" && $PKG_CONFIG $sofia_path > /dev/null 2>&1 ; then + found_sofia="yes" + sofia_config_path=$sofia_path + fi + + if test "$found_sofia" = "yes" ; then + UNIMRCP_SOFIA_INCLUDES="`$PKG_CONFIG --cflags $sofia_config_path`" + UNIMRCP_SOFIA_LIBS="`$PKG_CONFIG --libs $sofia_config_path`" + sofia_version="`$PKG_CONFIG --modversion $sofia_config_path`" + fi + fi + + if test "$found_sofia" != "yes" ; then + dnl Check for path to Sofia-SIP source/build tree + for dir in $sofia_path ; do + sofia_uadir="$dir/libsofia-sip-ua" + if test -d "$sofia_uadir"; then + found_sofia="yes" + UNIMRCP_SOFIA_INCLUDES="-I$sofia_uadir -I$sofia_uadir/bnf -I$sofia_uadir/features -I$sofia_uadir/http -I$sofia_uadir/ipt -I$sofia_uadir/iptsec -I$sofia_uadir/msg -I$sofia_uadir/nea -I$sofia_uadir/nta -I$sofia_uadir/nth -I$sofia_uadir/nua -I$sofia_uadir/sdp -I$sofia_uadir/sip -I$sofia_uadir/soa -I$sofia_uadir/sresolv -I$sofia_uadir/stun -I$sofia_uadir/su -I$sofia_uadir/tport -I$sofia_uadir/url" + UNIMRCP_SOFIA_LIBS="$sofia_uadir/libsofia-sip-ua.la" + sofia_version="`sed -n 's/#define SOFIA_SIP_VERSION.* "\(.*\)"/\1/p' $sofia_uadir/features/sofia-sip/sofia_features.h`" + break + fi + done + fi + + if test $found_sofia != "yes" ; then + if test -n "$PKG_CONFIG"; then + AC_MSG_ERROR(Cannot find Sofia-SIP - looked for sofia-config and libsofia-sip-ua in $sofia_path) + else + AC_MSG_ERROR(Cannot find Sofia-SIP - pkg-config not available, looked for libsofia-sip-ua in $sofia_path) + fi else AC_MSG_RESULT([$found_sofia]) AC_MSG_RESULT([$sofia_version]) case "$host" in *darwin*) - UNIMRCP_SOFIA_LIBS="$UNIMRCP_SOFIA_LIBS -framework CoreFoundation -framework SystemConfiguration" ;; + UNIMRCP_SOFIA_LIBS="$UNIMRCP_SOFIA_LIBS -framework CoreFoundation -framework SystemConfiguration" + ;; esac AC_SUBST(UNIMRCP_SOFIA_INCLUDES) diff --git a/libs/unimrcp/build/acmacros/sphinxbase.m4 b/libs/unimrcp/build/acmacros/sphinxbase.m4 deleted file mode 100644 index 801dbccd81..0000000000 --- a/libs/unimrcp/build/acmacros/sphinxbase.m4 +++ /dev/null @@ -1,50 +0,0 @@ -dnl UNIMRCP_CHECK_SPHINXBASE - -AC_DEFUN([UNIMRCP_CHECK_SPHINXBASE], -[ - AC_MSG_NOTICE([SphinxBase library configuration]) - - AC_MSG_CHECKING([for SphinxBase]) - AC_ARG_WITH(sphinxbase, - [ --with-sphinxbase=PATH prefix for installed SphinxBase or - path to SphinxBase build tree], - [sphinxbase_path=$withval], - [sphinxbase_path="/usr/local"] - ) - - found_sphinxbase="no" - sphinxbase_config="lib/pkgconfig/sphinxbase.pc" - sphinxbase_srcdir="src" - for dir in $sphinxbase_path ; do - cd $dir && sphinxbase_dir=`pwd` && cd - > /dev/null - if test -f "$dir/$sphinxbase_config"; then - found_sphinxbase="yes" - UNIMRCP_SPHINXBASE_INCLUDES="`pkg-config --cflags $dir/$sphinxbase_config`" - UNIMRCP_SPHINXBASE_LIBS="`pkg-config --libs $dir/$sphinxbase_config`" - sphinxbase_version="`pkg-config --modversion $dir/$sphinxbase_config`" - break - fi - if test -d "$dir/$sphinxbase_srcdir"; then - found_sphinxbase="yes" - UNIMRCP_SPHINXBASE_INCLUDES="-I$sphinxbase_dir/include" - UNIMRCP_SPHINXBASE_LIBS="$sphinxbase_dir/$sphinxbase_srcdir/libsphinxbase/libsphinxbase.la $sphinxbase_dir/$sphinxbase_srcdir/libsphinxad/libsphinxad.la" - sphinxbase_version="`pkg-config --modversion $sphinxbase_dir/sphinxbase.pc`" - break - fi - done - - if test x_$found_sphinxbase != x_yes; then - AC_MSG_ERROR(Cannot find SphinxBase - looked for sphinxbase-config:$sphinxbase_config and srcdir:$sphinxbase_srcdir in $sphinxbase_path) - else - AC_MSG_RESULT([$found_sphinxbase]) - AC_MSG_RESULT([$sphinxbase_version]) - -case "$host" in - *darwin*) - UNIMRCP_SPHINXBASE_LIBS="$UNIMRCP_SPHINXBASE_LIBS -framework CoreFoundation -framework SystemConfiguration" ;; -esac - - AC_SUBST(UNIMRCP_SPHINXBASE_INCLUDES) - AC_SUBST(UNIMRCP_SPHINXBASE_LIBS) - fi -]) diff --git a/libs/unimrcp/build/acmacros/uni_plugin.m4 b/libs/unimrcp/build/acmacros/uni_plugin.m4 new file mode 100644 index 0000000000..6a33b1b638 --- /dev/null +++ b/libs/unimrcp/build/acmacros/uni_plugin.m4 @@ -0,0 +1,45 @@ +dnl +dnl UNI_PLUGIN_ENABLED(name) +dnl +dnl where name is the name of the plugin. +dnl +dnl This macro can be used for a plugin which must be enabled by default. +dnl +dnl Adds the following argument to the configure script: +dnl +dnl --disable-$1-plugin +dnl +dnl Sets the following variable on exit: +dnl +dnl enable_$1_plugin : "yes" or "no" +dnl +AC_DEFUN([UNI_PLUGIN_ENABLED],[ + AC_ARG_ENABLE( + [$1-plugin], + [AC_HELP_STRING([--disable-$1-plugin],[exclude $1 plugin from build])], + [enable_$1_plugin="$enableval"], + [enable_$1_plugin="yes"]) +]) + +dnl +dnl UNI_PLUGIN_DISABLED(name) +dnl +dnl where name is the name of the plugin. +dnl +dnl This macro can be used for a plugin which must be disabled by default. +dnl +dnl Adds the following argument to the configure script: +dnl +dnl --enable-$1-plugin +dnl +dnl Sets the following variable on exit: +dnl +dnl enable_$1_plugin : "yes" or "no" +dnl +AC_DEFUN([UNI_PLUGIN_DISABLED],[ + AC_ARG_ENABLE( + [$1-plugin], + [AC_HELP_STRING([--enable-$1-plugin],[include $1 plugin in build])], + [enable_$1_plugin="$enableval"], + [enable_$1_plugin="no"]) +]) diff --git a/libs/unimrcp/build/init.d/unimrcp-server b/libs/unimrcp/build/init.d/unimrcp-server index 29be4f3653..3518e23fa1 100755 --- a/libs/unimrcp/build/init.d/unimrcp-server +++ b/libs/unimrcp/build/init.d/unimrcp-server @@ -1,271 +1,270 @@ -#!/bin/sh -# -# unimrcp-server This shell script takes care of starting and stopping the UniMRCP server. -# -# chkconfig: 2345 65 35 -# description: UniMRCP is an open source MRCP v1 & v2 server - -# Some global variables - -# Application -APP_NAME="unimrcpserver" -APP_LONG_NAME="unimrcpserver" -UNIMRCP_DIR="/usr/local/unimrcp/" - -EXEC="${UNIMRCP_DIR}bin/${APP_NAME} -d -o 2 -r ${UNIMRCP_DIR}" - -# sudo user -USERNAME=root - -# Priority at which to run the server. See "man nice" for valid priorities. -# nice is only used if a priority is specified. -PRIORITY= - -# Location of the pid file. -PIDDIR="/var/run/" -pid= - -LOG="/var/log/${APP_NAME}.log" - -if [ -e $PIDDIR ]; then -echo -else -mkdir $PIDDIR -fi - -# Allow configuration overrides in /etc/sysconfig/$APP_NAME -CONFIGFILE=/etc/sysconfig/$APP_NAME - -[ -x $CONFIGFILE ] && . $CONFIGFILE - -# Do not modify anything beyond this point -#----------------------------------------------------------------------------- - -# Get the fully qualified path to the script -case $0 in - /*) - SCRIPT="$0" - ;; - *) - PWD=`pwd` - SCRIPT="$PWD/$0" - ;; -esac - -# Change spaces to ":" so the tokens can be parsed. -SCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'` -# Get the real path to this script, resolving any symbolic links -TOKENS=`echo $SCRIPT | sed -e 's;/; ;g'` -REALPATH= -for C in $TOKENS; do -REALPATH="$REALPATH/$C" - while [ -h "$REALPATH" ] ; do -LS="`ls -ld "$REALPATH"`" - LINK="`expr "$LS" : '.*-> \(.*\)$'`" - if expr "$LINK" : '/.*' > /dev/null; then -REALPATH="$LINK" - else -REALPATH="`dirname "$REALPATH"`""/$LINK" - fi -done -done -# Change ":" chars back to spaces. -REALPATH=`echo $REALPATH | sed -e 's;:; ;g'` - -# Change the current directory to the location of the script -cd "`dirname "$REALPATH"`" - -chown $USERNAME $PIDDIR - -# Process ID -PIDFILE="$PIDDIR/$APP_NAME.pid" - -# Resolve the location of the 'ps' command -PSEXE="/usr/bin/ps" -if [ ! -x $PSEXE ] -then -PSEXE="/bin/ps" - if [ ! -x $PSEXE ] - then -echo "Unable to locate 'ps'." - echo "Please report this with the location on your system." - exit 1 - fi -fi - -# Build the nice clause -if [ "X$PRIORITY" = "X" ] -then -CMDNICE="" -else -CMDNICE="nice -$PRIORITY" -fi - -getpid() { - if [ -f $PIDFILE ] - then -if [ -r $PIDFILE ] - then -pid=`cat $PIDFILE` - if [ "X$pid" != "X" ] - then - # Verify that a process with this pid is still running. - pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` - if [ "X$pid" = "X" ] - then - # This is a stale pid file. - rm -f $PIDFILE - echo "Removed stale pid file: $PIDFILE" - fi -fi -else -echo "Cannot read $PIDFILE." - exit 1 - fi -fi -} - -testpid() { - pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` - if [ "X$pid" = "X" ] - then - # Process is gone so remove the pid file. - rm -f $PIDFILE - fi -} - -console() { - echo "Running $APP_LONG_NAME..." - getpid - if [ "X$pid" = "X" ] - then -exec sudo -u $USERNAME $CMDNICE $EXEC - else -echo "$APP_LONG_NAME is already running." - exit 1 - fi -} - -start() { - echo "Starting $APP_LONG_NAME..." - getpid - if [ "X$pid" = "X" ] - then -sudo -u $USERNAME $CMDNICE $EXEC - pid=`$PSEXE -C $APP_NAME -o pid=` -echo $pid -echo $pid > $PIDFILE - else -echo "$APP_LONG_NAME is already running." - exit 1 - fi -} - -stopit() { - echo "Stopping $APP_LONG_NAME..." - getpid - if [ "X$pid" = "X" ] - then -echo "$APP_LONG_NAME was not running." - else - # Running so try to stop it. - sudo -u $USERNAME kill $pid - if [ $? -ne 0 ] - then - # An explanation for the failure should have been given - echo "Unable to stop $APP_LONG_NAME." - exit 1 - fi - - # We can not predict how long it will take for the wrapper to - # actually stop as it depends on settings in wrapper.conf. - # Loop until it does. - savepid=$pid - CNT=0 - TOTCNT=0 - while [ "X$pid" != "X" ] - do - # Loop for up to 5 minutes - if [ "$TOTCNT" -lt "300" ] - then -if [ "$CNT" -lt "5" ] - then -CNT=`expr $CNT + 1` - else -echo "Waiting for $APP_LONG_NAME to exit..." - CNT=0 - fi -TOTCNT=`expr $TOTCNT + 1` - - sleep 1 - - testpid - else -pid= - fi -done - -pid=$savepid - testpid - if [ "X$pid" != "X" ] - then -echo "Timed out waiting for $APP_LONG_NAME to exit." - echo " Attempting a forced exit..." - kill -9 $pid - fi - -pid=$savepid - testpid - if [ "X$pid" != "X" ] - then -echo "Failed to stop $APP_LONG_NAME." - exit 1 - else -echo "Stopped $APP_LONG_NAME." - fi -fi -} - -status() { - getpid - if [ "X$pid" = "X" ] - then -echo "$APP_LONG_NAME is not running." - exit 1 - else -echo "$APP_LONG_NAME is running ($pid)." - exit 0 - fi -} - -case "$1" in - - 'console') - console - ;; - - 'start') - start - ;; - - 'stop') - stopit - ;; - - 'restart') - stopit - start - ;; - - 'status') - status - ;; - - *) - echo "Usage: $0 { console | start | stop | restart | status }" - exit 1 - ;; -esac - -exit 0 - +#!/bin/sh +# +# unimrcp-server This shell script takes care of starting and stopping the UniMRCP server. +# +# chkconfig: 2345 65 35 +# description: UniMRCP is an open source MRCP v1 & v2 server. + +# Some global variables + +# Application +APP_NAME="unimrcpserver" +APP_LONG_NAME="UniMRCP Server" +UNIMRCP_DIR="/usr/local/unimrcp/" +DAEMON_ARGS="-d -r ${UNIMRCP_DIR}" +APP_ARGS="-o 2" + +EXEC="${UNIMRCP_DIR}bin/${APP_NAME}" + +# sudo user +USERNAME=root + +# Priority at which to run the server. See "man nice" for valid priorities. +# nice is only used if a priority is specified. +PRIORITY= + +# Location of the pid file. +PIDDIR="/var/run/" +pid= + +if [ -e $PIDDIR ]; then + echo +else + mkdir $PIDDIR +fi + +# Allow configuration overrides in /etc/sysconfig/$APP_NAME +CONFIGFILE=/etc/sysconfig/$APP_NAME + +[ -x $CONFIGFILE ] && . $CONFIGFILE + +# Do not modify anything beyond this point +#----------------------------------------------------------------------------- + +# Get the fully qualified path to the script +case $0 in + /*) + SCRIPT="$0" + ;; + *) + PWD=`pwd` + SCRIPT="$PWD/$0" + ;; +esac + +# Change spaces to ":" so the tokens can be parsed. +SCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'` +# Get the real path to this script, resolving any symbolic links +TOKENS=`echo $SCRIPT | sed -e 's;/; ;g'` +REALPATH= +for C in $TOKENS; do + REALPATH="$REALPATH/$C" + while [ -h "$REALPATH" ] ; do + LS="`ls -ld "$REALPATH"`" + LINK="`expr "$LS" : '.*-> \(.*\)$'`" + if expr "$LINK" : '/.*' > /dev/null; then + REALPATH="$LINK" + else + REALPATH="`dirname "$REALPATH"`""/$LINK" + fi + done +done +# Change ":" chars back to spaces. +REALPATH=`echo $REALPATH | sed -e 's;:; ;g'` + +# Change the current directory to the location of the script +cd "`dirname "$REALPATH"`" + +chown $USERNAME $PIDDIR + +# Process ID +PIDFILE="$PIDDIR/$APP_NAME.pid" + +# Resolve the location of the 'ps' command +PSEXE="/usr/bin/ps" +if [ ! -x $PSEXE ] +then + PSEXE="/bin/ps" + if [ ! -x $PSEXE ] + then + echo "Unable to locate 'ps'." + echo "Please report this with the location on your system." + exit 1 + fi +fi + +# Build the nice clause +if [ "X$PRIORITY" = "X" ] +then + CMDNICE="" +else + CMDNICE="nice -$PRIORITY" +fi + +getpid() { + if [ -f $PIDFILE ] + then + if [ -r $PIDFILE ] + then + pid=`cat $PIDFILE` + if [ "X$pid" != "X" ] + then + # Verify that a process with this pid is still running. + pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + if [ "X$pid" = "X" ] + then + # This is a stale pid file. + rm -f $PIDFILE + echo "Removed stale pid file: $PIDFILE" + fi + fi + else + echo "Cannot read $PIDFILE." + exit 1 + fi + fi +} + +testpid() { + pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` + if [ "X$pid" = "X" ] + then + # Process is gone so remove the pid file. + rm -f $PIDFILE + fi +} + +console() { + echo "Running $APP_LONG_NAME..." + getpid + if [ "X$pid" = "X" ] + then + exec sudo -u $USERNAME $CMDNICE $EXEC $APP_ARGS + echo $pid > $PIDFILE + else + echo "$APP_LONG_NAME is already running." + exit 1 + fi +} + +start() { + echo "Starting $APP_LONG_NAME..." + getpid + if [ "X$pid" = "X" ] + then + sudo -u $USERNAME $CMDNICE $EXEC $DAEMON_ARGS $APP_ARGS + pid=`$PSEXE -C $APP_NAME -o pid=` + echo $pid > $PIDFILE + else + echo "$APP_LONG_NAME is already running." + exit 1 + fi +} + +stopit() { + echo "Stopping $APP_LONG_NAME..." + getpid + if [ "X$pid" = "X" ] + then + echo "$APP_LONG_NAME was not running." + else + # Running so try to stop it. + sudo -u $USERNAME kill $pid + if [ $? -ne 0 ] + then + # An explanation for the failure should have been given + echo "Unable to stop $APP_LONG_NAME." + exit 1 + fi + + # We can not predict how long it will take for the wrapper to + # actually stop as it depends on settings in wrapper.conf. + # Loop until it does. + savepid=$pid + CNT=0 + TOTCNT=0 + while [ "X$pid" != "X" ] + do + # Loop for up to 5 minutes + if [ "$TOTCNT" -lt "300" ] + then + if [ "$CNT" -lt "5" ] + then + CNT=`expr $CNT + 1` + else + echo "Waiting for $APP_LONG_NAME to exit..." + CNT=0 + fi + TOTCNT=`expr $TOTCNT + 1` + + sleep 1 + + testpid + else + pid= + fi + done + + pid=$savepid + testpid + if [ "X$pid" != "X" ] + then + echo "Timed out waiting for $APP_LONG_NAME to exit." + echo " Attempting a forced exit..." + kill -9 $pid + fi + + pid=$savepid + testpid + if [ "X$pid" != "X" ] + then + echo "Failed to stop $APP_LONG_NAME." + exit 1 + else + echo "Stopped $APP_LONG_NAME." + fi + fi +} + +status() { + getpid + if [ "X$pid" = "X" ] + then + echo "$APP_LONG_NAME is not running." + exit 1 + else + echo "$APP_LONG_NAME is running ($pid)." + exit 0 + fi +} + +case "$1" in + + 'console') + console + ;; + + 'start') + start + ;; + + 'stop') + stopit + ;; + + 'restart') + stopit + start + ;; + + 'status') + status + ;; + + *) + echo "Usage: $0 { console | start | stop | restart | status }" + exit 1 + ;; +esac + +exit 0 diff --git a/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in b/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in index f95c6822f7..7fe3f1c130 100644 --- a/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in +++ b/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ @UNIMRCP_APU_INCLUDES@ +includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ Name: unimrcpclient Description: UniMRCP Client Stack diff --git a/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in b/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in index e0d93cc005..df78b8ea7f 100644 --- a/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in +++ b/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ @UNIMRCP_APU_INCLUDES@ +includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ Name: unimrcpplugin Description: UniMRCP Server Plugin diff --git a/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in b/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in index fcb221302e..3ed91ecd02 100644 --- a/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in +++ b/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ @UNIMRCP_APU_INCLUDES@ +includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ Name: unimrcpserver Description: UniMRCP Server Stack diff --git a/libs/unimrcp/build/vsprops/apr.props b/libs/unimrcp/build/props/apr.props similarity index 76% rename from libs/unimrcp/build/vsprops/apr.props rename to libs/unimrcp/build/props/apr.props index ef8f3c8ec9..8e3f475bb3 100644 --- a/libs/unimrcp/build/vsprops/apr.props +++ b/libs/unimrcp/build/props/apr.props @@ -1,27 +1,33 @@ - - - - - - - $(LibRootDir)libs\apr - $(LibRootDir)libs\apr-util - $(LibRootDir)libs\apr-iconv - - - - $(AprDir)\include;$(AprUtilDir)\include;%(AdditionalIncludeDirectories) - - - - - $(AprDir) - - - $(AprUtilDir) - - - $(AprIconvDir) - - + + + + + + + $(LibRootDir)libs\apr + $(LibRootDir)libs\apr-util + $(LibRootDir)libs\apr-iconv + + + <_ProjectFileVersion>10.0.30319.1 + + + true + + + + $(AprDir)\include;$(AprUtilDir)\include;%(AdditionalIncludeDirectories) + + + + + $(AprDir) + + + $(AprUtilDir) + + + $(AprIconvDir) + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/apt.props b/libs/unimrcp/build/props/apt.props similarity index 72% rename from libs/unimrcp/build/vsprops/apt.props rename to libs/unimrcp/build/props/apt.props index ae6300b1cf..89c5547c33 100644 --- a/libs/unimrcp/build/vsprops/apt.props +++ b/libs/unimrcp/build/props/apt.props @@ -1,15 +1,18 @@ - - - - - - - true - - - - $(ProjectRootDir)libs\apr-toolkit\include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + true + + + + $(ProjectRootDir)libs\apr-toolkit\include;%(AdditionalIncludeDirectories) + APT_STATIC_LIB;%(PreprocessorDefinitions) + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/mpf.props b/libs/unimrcp/build/props/mpf.props similarity index 67% rename from libs/unimrcp/build/vsprops/mpf.props rename to libs/unimrcp/build/props/mpf.props index 6a7ef7070a..8e46c5dd2a 100644 --- a/libs/unimrcp/build/vsprops/mpf.props +++ b/libs/unimrcp/build/props/mpf.props @@ -1,12 +1,18 @@ - - - - - - - - $(ProjectRootDir)libs\mpf\include;%(AdditionalIncludeDirectories) - MPF_STATIC_LIB;%(PreprocessorDefinitions) - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + true + + + + $(ProjectRootDir)libs\mpf\include;%(AdditionalIncludeDirectories) + MPF_STATIC_LIB;%(PreprocessorDefinitions) + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/mrcp.props b/libs/unimrcp/build/props/mrcp.props similarity index 76% rename from libs/unimrcp/build/vsprops/mrcp.props rename to libs/unimrcp/build/props/mrcp.props index c4006c517e..14f8a4683d 100644 --- a/libs/unimrcp/build/vsprops/mrcp.props +++ b/libs/unimrcp/build/props/mrcp.props @@ -1,15 +1,18 @@ - - - - - - - true - - - - $(ProjectRootDir)libs\mrcp\include;$(ProjectRootDir)libs\mrcp\message\include;$(ProjectRootDir)libs\mrcp\control\include;$(ProjectRootDir)libs\mrcp\resources\include;%(AdditionalIncludeDirectories) - MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + true + + + + $(ProjectRootDir)libs\mrcp\include;$(ProjectRootDir)libs\mrcp\message\include;$(ProjectRootDir)libs\mrcp\control\include;$(ProjectRootDir)libs\mrcp\resources\include;%(AdditionalIncludeDirectories) + MRCP_STATIC_LIB;%(PreprocessorDefinitions) + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/mrcpclient.props b/libs/unimrcp/build/props/mrcpclient.props similarity index 96% rename from libs/unimrcp/build/vsprops/mrcpclient.props rename to libs/unimrcp/build/props/mrcpclient.props index b650e07d91..4e552bd3fd 100644 --- a/libs/unimrcp/build/vsprops/mrcpclient.props +++ b/libs/unimrcp/build/props/mrcpclient.props @@ -1,15 +1,15 @@ - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - - - - $(ProjectRootDir)libs\mrcp-client\include;%(AdditionalIncludeDirectories) - - + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)libs\mrcp-client\include;%(AdditionalIncludeDirectories) + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/mrcpengine.props b/libs/unimrcp/build/props/mrcpengine.props new file mode 100644 index 0000000000..5b1ee1b5ca --- /dev/null +++ b/libs/unimrcp/build/props/mrcpengine.props @@ -0,0 +1,15 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)libs\mrcp-engine\include;%(AdditionalIncludeDirectories) + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/mrcpserver.props b/libs/unimrcp/build/props/mrcpserver.props new file mode 100644 index 0000000000..94e5e8aef2 --- /dev/null +++ b/libs/unimrcp/build/props/mrcpserver.props @@ -0,0 +1,16 @@ + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)libs\mrcp-server\include;%(AdditionalIncludeDirectories) + + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/mrcpsignaling.props b/libs/unimrcp/build/props/mrcpsignaling.props similarity index 63% rename from libs/unimrcp/build/vsprops/mrcpsignaling.props rename to libs/unimrcp/build/props/mrcpsignaling.props index ee74131a39..dbe9aa32cf 100644 --- a/libs/unimrcp/build/vsprops/mrcpsignaling.props +++ b/libs/unimrcp/build/props/mrcpsignaling.props @@ -1,12 +1,15 @@ - - - - - - - - - $(ProjectRootDir)libs\mrcp-signaling\include;%(AdditionalIncludeDirectories) - - + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)libs\mrcp-signaling\include;%(AdditionalIncludeDirectories) + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/mrcpv2transport.props b/libs/unimrcp/build/props/mrcpv2transport.props similarity index 70% rename from libs/unimrcp/build/vsprops/mrcpv2transport.props rename to libs/unimrcp/build/props/mrcpv2transport.props index dcefa1ddbe..8b65c83982 100644 --- a/libs/unimrcp/build/vsprops/mrcpv2transport.props +++ b/libs/unimrcp/build/props/mrcpv2transport.props @@ -1,11 +1,14 @@ - - - - - - - - $(ProjectRootDir)libs\mrcpv2-transport\include;%(AdditionalIncludeDirectories) - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)libs\mrcpv2-transport\include;%(AdditionalIncludeDirectories) + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/sdk/unimrcpclient.props b/libs/unimrcp/build/props/sdk/unimrcpclient.props new file mode 100644 index 0000000000..b9e764ee52 --- /dev/null +++ b/libs/unimrcp/build/props/sdk/unimrcpclient.props @@ -0,0 +1,14 @@ + + + + + + + + + + libunimrcpclient.lib mrcpsofiasip.lib mrcpunirtsp.lib unirtsp.lib mrcpclient.lib mrcpv2transport.lib mrcpsignaling.lib libsofia_sip_ua.lib ws2_32.lib winmm.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/sdk/unimrcpplugin.props b/libs/unimrcp/build/props/sdk/unimrcpplugin.props new file mode 100644 index 0000000000..6d69aea52b --- /dev/null +++ b/libs/unimrcp/build/props/sdk/unimrcpplugin.props @@ -0,0 +1,14 @@ + + + + + + + + + + mrcpengine.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/sdk/unimrcpsdk.props b/libs/unimrcp/build/props/sdk/unimrcpsdk.props new file mode 100644 index 0000000000..0334d6a0fe --- /dev/null +++ b/libs/unimrcp/build/props/sdk/unimrcpsdk.props @@ -0,0 +1,23 @@ + + + + + C:\Program Files\UniMRCP + + + + + $(ProjectRootDir)\include;%(AdditionalIncludeDirectories) + APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) + + + $(ProjectRootDir)\lib;%(AdditionalLibraryDirectories) + mrcp.lib;mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + $(ProjectRootDir) + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/sdk/unimrcpserver.props b/libs/unimrcp/build/props/sdk/unimrcpserver.props new file mode 100644 index 0000000000..979a32781e --- /dev/null +++ b/libs/unimrcp/build/props/sdk/unimrcpserver.props @@ -0,0 +1,14 @@ + + + + + + + + + + libunimrcpserver.lib mrcpsofiasip.lib mrcpunirtsp.lib unirtsp.lib mrcpserver.lib mrcpv2transport.lib mrcpsignaling.lib mrcpengine.lib libsofia_sip_ua.lib ws2_32.lib winmm.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/sofiasip.props b/libs/unimrcp/build/props/sofiasip.props similarity index 66% rename from libs/unimrcp/build/vsprops/sofiasip.props rename to libs/unimrcp/build/props/sofiasip.props index ad901994ce..0620099b0c 100644 --- a/libs/unimrcp/build/vsprops/sofiasip.props +++ b/libs/unimrcp/build/props/sofiasip.props @@ -1,19 +1,25 @@ - - - - - - - $(LibRootDir)libs\sofia-sip - - - - $(SofiaDir)\win32;$(SofiaDir)\libsofia-sip-ua\su;$(SofiaDir)\libsofia-sip-ua\nua;$(SofiaDir)\libsofia-sip-ua\url;$(SofiaDir)\libsofia-sip-ua\sip;$(SofiaDir)\libsofia-sip-ua\msg;$(SofiaDir)\libsofia-sip-ua\sdp;$(SofiaDir)\libsofia-sip-ua\nta;$(SofiaDir)\libsofia-sip-ua\nea;$(SofiaDir)\libsofia-sip-ua\soa;$(SofiaDir)\libsofia-sip-ua\iptsec;$(SofiaDir)\libsofia-sip-ua\bnf;$(SofiaDir)\libsofia-sip-ua\features;%(AdditionalIncludeDirectories) - - - - - $(SofiaDir) - - + + + + + + + $(LibRootDir)libs\sofia-sip + + + <_ProjectFileVersion>10.0.30319.1 + + + true + + + + $(SofiaDir)\win32;$(SofiaDir)\libsofia-sip-ua\su;$(SofiaDir)\libsofia-sip-ua\nua;$(SofiaDir)\libsofia-sip-ua\url;$(SofiaDir)\libsofia-sip-ua\sip;$(SofiaDir)\libsofia-sip-ua\msg;$(SofiaDir)\libsofia-sip-ua\sdp;$(SofiaDir)\libsofia-sip-ua\nta;$(SofiaDir)\libsofia-sip-ua\nea;$(SofiaDir)\libsofia-sip-ua\soa;$(SofiaDir)\libsofia-sip-ua\iptsec;$(SofiaDir)\libsofia-sip-ua\bnf;$(SofiaDir)\libsofia-sip-ua\features;$(SofiaDir)\libsofia-sip-ua\tport;%(AdditionalIncludeDirectories) + + + + + $(SofiaDir) + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/unibase.props b/libs/unimrcp/build/props/unibase.props similarity index 88% rename from libs/unimrcp/build/vsprops/unibase.props rename to libs/unimrcp/build/props/unibase.props index 69db3e3101..2573021220 100644 --- a/libs/unimrcp/build/vsprops/unibase.props +++ b/libs/unimrcp/build/props/unibase.props @@ -1,28 +1,29 @@ - - - - $(ProjectDir)..\..\ - $(SolutionDir) - - - <_ProjectFileVersion>10.0.30319.1 - - - true - - - WIN32;%(PreprocessorDefinitions) - Level4 - true - 4100;%(DisableSpecificWarnings) - - - - - $(ProjectRootDir) - - - $(LibRootDir) - - + + + + $(ProjectDir)..\..\ + $(SolutionDir) + + + <_ProjectFileVersion>10.0.30319.1 + + + true + + + + WIN32;%(PreprocessorDefinitions) + Level4 + true + 4100;%(DisableSpecificWarnings) + + + + + $(ProjectRootDir) + + + $(LibRootDir) + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/unibin-x64.props b/libs/unimrcp/build/props/unibin-x64.props new file mode 100644 index 0000000000..0d5b4dda41 --- /dev/null +++ b/libs/unimrcp/build/props/unibin-x64.props @@ -0,0 +1,21 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(PlatformName)\$(Configuration)\bin\ + $(PlatformName)\$(Configuration)\ + + + + _WIN64;%(PreprocessorDefinitions) + + + $(AprDir)\$(Platform)\$(Configuration);$(AprUtilDir)\$(Platform)\$(Configuration);$(SofiaDir)\win32\libsofia-sip-ua\$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\lib;$(SolutionDir)$(Platform)\$(Configuration)\bin;%(AdditionalLibraryDirectories) + MachineX64 + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/unibin.props b/libs/unimrcp/build/props/unibin.props new file mode 100644 index 0000000000..bb83b9ed65 --- /dev/null +++ b/libs/unimrcp/build/props/unibin.props @@ -0,0 +1,18 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\bin\ + $(Configuration)\ + + + + $(AprDir)\$(Configuration);$(AprUtilDir)\$(Configuration);$(SofiaDir)\win32\libsofia-sip-ua\$(Configuration);$(SolutionDir)$(Configuration)\lib;$(SolutionDir)$(Configuration)\bin;%(AdditionalLibraryDirectories) + MachineX86 + + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/unidebug.props b/libs/unimrcp/build/props/unidebug.props similarity index 71% rename from libs/unimrcp/build/vsprops/unidebug.props rename to libs/unimrcp/build/props/unidebug.props index b345085066..7c3d8d81fe 100644 --- a/libs/unimrcp/build/vsprops/unidebug.props +++ b/libs/unimrcp/build/props/unidebug.props @@ -1,19 +1,25 @@ - - - - - <_ProjectFileVersion>10.0.30319.1 - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - ProgramDatabase - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + true + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + ProgramDatabase + + + true + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/unilib-x64.props b/libs/unimrcp/build/props/unilib-x64.props new file mode 100644 index 0000000000..e5e25acc2e --- /dev/null +++ b/libs/unimrcp/build/props/unilib-x64.props @@ -0,0 +1,13 @@ + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(PlatformName)\$(Configuration)\lib\ + $(PlatformName)\$(Configuration)\ + + + + _WIN64;%(PreprocessorDefinitions) + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/unilib.props b/libs/unimrcp/build/props/unilib.props new file mode 100644 index 0000000000..c77e94699e --- /dev/null +++ b/libs/unimrcp/build/props/unilib.props @@ -0,0 +1,8 @@ + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\lib\ + $(Configuration)\ + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/unimrcpclient.props b/libs/unimrcp/build/props/unimrcpclient.props new file mode 100644 index 0000000000..78f2b87025 --- /dev/null +++ b/libs/unimrcp/build/props/unimrcpclient.props @@ -0,0 +1,23 @@ + + + + + + + + libunimrcpclient.lib;mrcpsofiasip.lib;mrcpunirtsp.lib;unirtsp.lib;mrcpclient.lib;mrcpv2transport.lib;mrcpsignaling.lib;mrcp.lib;mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;libsofia_sip_ua.lib;ws2_32.lib;winmm.lib + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)platforms\libunimrcp-client\include;$(ProjectRootDir)build;%(AdditionalIncludeDirectories) + + + + + $(UniMRCPClientLibs) + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/unimrcpserver.props b/libs/unimrcp/build/props/unimrcpserver.props new file mode 100644 index 0000000000..97c0f9808f --- /dev/null +++ b/libs/unimrcp/build/props/unimrcpserver.props @@ -0,0 +1,23 @@ + + + + + + + + libunimrcpserver.lib;mrcpsofiasip.lib;mrcpunirtsp.lib;unirtsp.lib;mrcpserver.lib;mrcpv2transport.lib;mrcpsignaling.lib;mrcpengine.lib;mrcp.lib;mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;libsofia_sip_ua.lib;ws2_32.lib;winmm.lib + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)platforms\libunimrcp-server\include;$(ProjectRootDir)build;%(AdditionalIncludeDirectories) + + + + + $(UniMRCPServerLibs) + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/uniplugin-x64.props b/libs/unimrcp/build/props/uniplugin-x64.props new file mode 100644 index 0000000000..7dc181ca94 --- /dev/null +++ b/libs/unimrcp/build/props/uniplugin-x64.props @@ -0,0 +1,22 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(PlatformName)\$(Configuration)\plugin\ + $(PlatformName)\$(Configuration)\ + + + + _WIN64;%(PreprocessorDefinitions) + + + $(AprDir)\$(Platform)\$(Configuration);$(AprUtilDir)\$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\lib;%(AdditionalLibraryDirectories) + mrcpengine.lib;mrcp.lib;mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;ws2_32.lib;%(AdditionalDependencies) + MachineX64 + + + \ No newline at end of file diff --git a/libs/unimrcp/build/props/uniplugin.props b/libs/unimrcp/build/props/uniplugin.props new file mode 100644 index 0000000000..09dbe53c17 --- /dev/null +++ b/libs/unimrcp/build/props/uniplugin.props @@ -0,0 +1,19 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\plugin\ + $(Configuration)\ + + + + $(AprDir)\$(Configuration);$(AprUtilDir)\$(Configuration);$(SolutionDir)$(Configuration)\lib;%(AdditionalLibraryDirectories) + mrcpengine.lib;mrcp.lib;mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;ws2_32.lib;%(AdditionalDependencies) + MachineX86 + + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/unirelease.props b/libs/unimrcp/build/props/unirelease.props similarity index 77% rename from libs/unimrcp/build/vsprops/unirelease.props rename to libs/unimrcp/build/props/unirelease.props index 8fee91840a..a2a832025a 100644 --- a/libs/unimrcp/build/vsprops/unirelease.props +++ b/libs/unimrcp/build/props/unirelease.props @@ -1,16 +1,18 @@ - - - - - <_ProjectFileVersion>10.0.30319.1 - - - - NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - ProgramDatabase - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + NDEBUG;%(PreprocessorDefinitions) + MultiThreadedDLL + + + ProgramDatabase + + \ No newline at end of file diff --git a/libs/unimrcp/build/vsprops/unirtsp.props b/libs/unimrcp/build/props/unirtsp.props similarity index 86% rename from libs/unimrcp/build/vsprops/unirtsp.props rename to libs/unimrcp/build/props/unirtsp.props index 43ccdedd95..c872838994 100644 --- a/libs/unimrcp/build/vsprops/unirtsp.props +++ b/libs/unimrcp/build/props/unirtsp.props @@ -1,15 +1,15 @@ - - - - - - - <_ProjectFileVersion>10.0.30319.1 - - - - $(ProjectRootDir)libs\uni-rtsp\include;%(AdditionalIncludeDirectories) - RTSP_STATIC_LIB;%(PreprocessorDefinitions) - - + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + $(ProjectRootDir)libs\uni-rtsp\include;%(AdditionalIncludeDirectories) + RTSP_STATIC_LIB;%(PreprocessorDefinitions) + + \ No newline at end of file diff --git a/libs/unimrcp/build/rules/uniclientapp.am b/libs/unimrcp/build/rules/uniclientapp.am new file mode 100644 index 0000000000..2b1b97d1c3 --- /dev/null +++ b/libs/unimrcp/build/rules/uniclientapp.am @@ -0,0 +1,24 @@ +MAINTAINERCLEANFILES = Makefile.in + +# Includes +UNIMRCP_CLIENTAPP_INCLUDES = -I$(top_srcdir)/platforms/libunimrcp-client/include \ + -I$(top_srcdir)/libs/mrcp-client/include \ + -I$(top_srcdir)/libs/mrcp-signaling/include \ + -I$(top_srcdir)/libs/mrcpv2-transport/include \ + -I$(top_srcdir)/libs/mrcp/include \ + -I$(top_srcdir)/libs/mrcp/message/include \ + -I$(top_srcdir)/libs/mrcp/control/include \ + -I$(top_srcdir)/libs/mrcp/resources/include \ + -I$(top_srcdir)/libs/mpf/include \ + -I$(top_srcdir)/libs/apr-toolkit/include \ + -I$(top_srcdir)/build \ + $(UNIMRCP_APR_INCLUDES) + +# Libraries (LDADD) +UNIMRCP_CLIENTAPP_LIBS = $(top_builddir)/platforms/libunimrcp-client/libunimrcpclient.la + +# Linker options (LDFLAGS) +UNIMRCP_CLIENTAPP_OPTS = +if ISMAC +UNIMRCP_CLIENTAPP_OPTS += -framework CoreFoundation -framework SystemConfiguration +endif diff --git a/libs/unimrcp/build/rules/uniclientlib.am b/libs/unimrcp/build/rules/uniclientlib.am new file mode 100644 index 0000000000..89d173e61a --- /dev/null +++ b/libs/unimrcp/build/rules/uniclientlib.am @@ -0,0 +1,30 @@ +MAINTAINERCLEANFILES = Makefile.in + +# Includes +UNIMRCP_CLIENTLIB_INCLUDES = -I$(top_srcdir)/modules/mrcp-sofiasip/include \ + -I$(top_srcdir)/modules/mrcp-unirtsp/include \ + -I$(top_srcdir)/libs/mrcp-client/include \ + -I$(top_srcdir)/libs/mrcp-signaling/include \ + -I$(top_srcdir)/libs/mrcpv2-transport/include \ + -I$(top_srcdir)/libs/mrcp/include \ + -I$(top_srcdir)/libs/mrcp/message/include \ + -I$(top_srcdir)/libs/mrcp/control/include \ + -I$(top_srcdir)/libs/mrcp/resources/include \ + -I$(top_srcdir)/libs/mpf/include \ + -I$(top_srcdir)/libs/apr-toolkit/include \ + -I$(top_srcdir)/build \ + $(UNIMRCP_APR_INCLUDES) + +# Libraries (LIBADD) +UNIMRCP_CLIENTLIB_LIBS = $(top_builddir)/modules/mrcp-sofiasip/libmrcpsofiasip.la \ + $(top_builddir)/modules/mrcp-unirtsp/libmrcpunirtsp.la \ + $(top_builddir)/libs/mrcpv2-transport/libmrcpv2transport.la \ + $(top_builddir)/libs/mrcp-client/libmrcpclient.la \ + $(top_builddir)/libs/mrcp-signaling/libmrcpsignaling.la \ + $(top_builddir)/libs/mrcp/libmrcp.la \ + $(top_builddir)/libs/mpf/libmpf.la \ + $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ + $(UNIMRCP_APR_LIBS) $(UNIMRCP_SOFIA_LIBS) -lm + +# Linker options (LDFLAGS) +UNIMRCP_CLIENTLIB_OPTS = $(UNI_LT_VERSION) diff --git a/libs/unimrcp/build/rules/uniplugin.am b/libs/unimrcp/build/rules/uniplugin.am new file mode 100644 index 0000000000..caf0de48ad --- /dev/null +++ b/libs/unimrcp/build/rules/uniplugin.am @@ -0,0 +1,14 @@ +MAINTAINERCLEANFILES = Makefile.in + +# Includes +UNIMRCP_PLUGIN_INCLUDES = -I$(top_srcdir)/libs/mrcp-engine/include \ + -I$(top_srcdir)/libs/mrcp/include \ + -I$(top_srcdir)/libs/mrcp/message/include \ + -I$(top_srcdir)/libs/mrcp/control/include \ + -I$(top_srcdir)/libs/mrcp/resources/include \ + -I$(top_srcdir)/libs/mpf/include \ + -I$(top_srcdir)/libs/apr-toolkit/include \ + $(UNIMRCP_APR_INCLUDES) + +# Linker options (LDFLAGS) +UNIMRCP_PLUGIN_OPTS = -module $(PLUGIN_LT_VERSION) diff --git a/libs/unimrcp/build/rules/uniserverapp.am b/libs/unimrcp/build/rules/uniserverapp.am new file mode 100644 index 0000000000..957b0e75cd --- /dev/null +++ b/libs/unimrcp/build/rules/uniserverapp.am @@ -0,0 +1,25 @@ +MAINTAINERCLEANFILES = Makefile.in + +# Includes +UNIMRCP_SERVERAPP_INCLUDES = -I$(top_srcdir)/platforms/libunimrcp-server/include \ + -I$(top_srcdir)/libs/mrcp-server/include \ + -I$(top_srcdir)/libs/mrcp-engine/include \ + -I$(top_srcdir)/libs/mrcp-signaling/include \ + -I$(top_srcdir)/libs/mrcpv2-transport/include \ + -I$(top_srcdir)/libs/mrcp/include \ + -I$(top_srcdir)/libs/mrcp/message/include \ + -I$(top_srcdir)/libs/mrcp/control/include \ + -I$(top_srcdir)/libs/mrcp/resources/include \ + -I$(top_srcdir)/libs/mpf/include \ + -I$(top_srcdir)/libs/apr-toolkit/include \ + -I$(top_srcdir)/build \ + $(UNIMRCP_APR_INCLUDES) + +# Libraries (LDADD) +UNIMRCP_SERVERAPP_LIBS = $(top_builddir)/platforms/libunimrcp-server/libunimrcpserver.la + +# Linker options (LDFLAGS) +UNIMRCP_SERVERAPP_OPTS = +if ISMAC +UNIMRCP_SERVERAPP_OPTS += -framework CoreFoundation -framework SystemConfiguration +endif diff --git a/libs/unimrcp/build/rules/uniserverlib.am b/libs/unimrcp/build/rules/uniserverlib.am new file mode 100644 index 0000000000..b933796e42 --- /dev/null +++ b/libs/unimrcp/build/rules/uniserverlib.am @@ -0,0 +1,32 @@ +MAINTAINERCLEANFILES = Makefile.in + +# Includes +UNIMRCP_SERVERLIB_INCLUDES = -I$(top_srcdir)/modules/mrcp-sofiasip/include \ + -I$(top_srcdir)/modules/mrcp-unirtsp/include \ + -I$(top_srcdir)/libs/mrcp-server/include \ + -I$(top_srcdir)/libs/mrcp-engine/include \ + -I$(top_srcdir)/libs/mrcp-signaling/include \ + -I$(top_srcdir)/libs/mrcpv2-transport/include \ + -I$(top_srcdir)/libs/mrcp/include \ + -I$(top_srcdir)/libs/mrcp/message/include \ + -I$(top_srcdir)/libs/mrcp/control/include \ + -I$(top_srcdir)/libs/mrcp/resources/include \ + -I$(top_srcdir)/libs/mpf/include \ + -I$(top_srcdir)/libs/apr-toolkit/include \ + -I$(top_srcdir)/build \ + $(UNIMRCP_APR_INCLUDES) + +# Libraries (LIBADD) +UNIMRCP_SERVERLIB_LIBS = $(top_builddir)/modules/mrcp-sofiasip/libmrcpsofiasip.la \ + $(top_builddir)/modules/mrcp-unirtsp/libmrcpunirtsp.la \ + $(top_builddir)/libs/mrcp-server/libmrcpserver.la \ + $(top_builddir)/libs/mrcp-signaling/libmrcpsignaling.la \ + $(top_builddir)/libs/mrcpv2-transport/libmrcpv2transport.la \ + $(top_builddir)/libs/mrcp-engine/libmrcpengine.la \ + $(top_builddir)/libs/mrcp/libmrcp.la \ + $(top_builddir)/libs/mpf/libmpf.la \ + $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ + $(UNIMRCP_APR_LIBS) $(UNIMRCP_SOFIA_LIBS) -lm + +# Linker options (LDFLAGS) +UNIMRCP_SERVERLIB_OPTS = $(UNI_LT_VERSION) diff --git a/libs/unimrcp/build/svnrev/Makefile.am b/libs/unimrcp/build/svnrev/Makefile.am deleted file mode 100644 index 78f9a457c5..0000000000 --- a/libs/unimrcp/build/svnrev/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) - -noinst_PROGRAMS = svnrev -svnrev_LDADD = $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) -svnrev_SOURCES = svnrev.c - -rev: - ./svnrev -rsvnrev.input -p../../ -o../uni_revision.h diff --git a/libs/unimrcp/build/svnrev/svnrev.c b/libs/unimrcp/build/svnrev/svnrev.c deleted file mode 100644 index 154b07ef3f..0000000000 --- a/libs/unimrcp/build/svnrev/svnrev.c +++ /dev/null @@ -1,381 +0,0 @@ -/* SvnRev - * - * This utility retrieves the highest number that follows the "$Id: $" keyword - * or a combination of the $Rev: $ and $Date: $ keywords. The Subversion - * version control system expands these keywords and keeps them up to date. - * For an example of the tag, see the end of this comment. - * - * Details on the usage and the operation of this utility is available on-line - * at http://www.compuphase.com/svnrev.htm. - * - * - * Acknowledgements - * - * The support for .java files is contributed by Tom McCann (tommc@spoken.com). - * The option for prefixing and/or suffixing the build number (in the string - * constant SVN_REVSTR) was suggested by Robert Nitzel. - * - * - * License - * - * Copyright (c) 2005-2009, ITB CompuPhase (www.compuphase.com). - * - * This software is provided "as-is", without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in - * a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: svnrev.c 1497 2010-02-12 17:20:21Z achaloyan $ - */ - -#include -#include -#include - -#include -#include - - -#if defined __WIN32__ || defined _Win32 || defined _WIN32 - #define DIRSEP '\\' -#elif defined macintosh - #define DIRSEP ':' -#else - /* assume Linux/Unix */ - #define DIRSEP '/' -#endif - -#define MAX_LINELENGTH 512 -#define MAX_SYMBOLLENGTH 32 - -static void about(void) -{ - printf("svnrev 1.7.\n\n"); - printf("Usage: svnrev [options] [input [...]]\n\n" - "Options:\n" - "-ofilename\tOutput filename for the file with the build number. When no\n" - "\t\tfilename follows \"-o\", the result is written to stdout. The\n" - "\t\tdefault filename is \"svnrev.h\" for C/C++ and \"VersionInfo.java\"\n" - "\t\tfor Java.\n\n" - "-fpattern\tFormat: Adds text before or after the build number in the\n" - "\t\tconstant SVN_REVSTR. The pattern has the form \"text#text\"\n" - "\t\t(without the quotes) where \"text\" is arbitrary text and \"#\"\n" - "\t\twill be replaced by the build number.\n\n" - "-i\t\tIncremental: this option should be used when the list of input\n" - "\t\tfiles is a subset of all files in the project. When -i is\n" - "\t\tpresent, svnrev also scans the output file that was generated\n" - "\t\ton a previous run.\n\n" - "-jname\t\tJava: this option writes a java package file instead of a C/C++\n" - "\t\theader file. The name of the Java package must follow the\n" - "\t\toption (this is not the filename).\n\n" - "-v\t\tVerbose: prints the names of files that are modified since the\n" - "\t\tlast commit (into version control) to stderr.\n"); - exit(1); -} - -static void processfile(const char *name, int failsilent, - int *max_build, int *accum_build, - int *max_year, int *max_month, int *max_day, - int *ismodified) - -{ - char str[MAX_LINELENGTH], str_base[MAX_LINELENGTH]; - char name_base[MAX_LINELENGTH]; - char *p1; - FILE *fp, *fp_base; - int build, maj_build; - int year, month, day; - int cnt; - char modchar; - - /* since we also want to verify whether the file is modified in version - * control, get the path to the working copy name - * for every source file "\, the "working copy" base can - * be found in "\.svn\text-base\.svn-base" - */ - if ((p1 = strrchr(name, DIRSEP)) != NULL) { - ++p1; /* skip directory separator character ('\' in Windows, '/' in Linux) */ - strncpy(name_base, name, (int)(p1 - name)); - name_base[(int)(p1 - name)] = '\0'; - } else { - name_base[0] = '\0'; - p1 = (char*)name; - } /* if */ - sprintf(name_base + strlen(name_base), ".svn%ctext-base%c%s.svn-base", - DIRSEP, DIRSEP, p1); - - /* first extract the revision keywords */ - fp = fopen(name, "r"); - if (fp == NULL) { - if (!failsilent) - fprintf(stderr, "Failed to open input file '%s'\n", name); - return; - } /* if */ - fp_base = fopen(name_base, "r"); /* fail silently */ - build = 0; - maj_build = 0; /* RCS / CVS */ - year = month = day = 0; - - while (fgets(str, sizeof str, fp) != NULL) { - if (fp_base == NULL || fgets(str_base, sizeof str_base, fp_base) == NULL) - str_base[0] = '\0'; - if ((p1 = strstr(str, "$Id:")) != NULL && strchr(p1+1, '$') != NULL) { - if (sscanf(p1, "$Id: %*s %d %d-%d-%d", &build, &year, &month, &day) < 4 - && sscanf(p1, "$Id: %*s %d %d/%d/%d", &build, &year, &month, &day) < 4) - if (sscanf(p1, "$Id: %*s %d.%d %d-%d-%d", &maj_build, &build, &year, &month, &day) < 5) - sscanf(p1, "$Id: %*s %d.%d %d/%d/%d", &maj_build, &build, &year, &month, &day); - } else if ((p1 = strstr(str, "$Rev:")) != NULL && strchr(p1+1, '$') != NULL) { - if (sscanf(p1, "$Rev: %d.%d", &maj_build, &build) < 2) { - sscanf(p1, "$Rev: %d", &build); - maj_build = 0; - } /* if */ - } else if ((p1 = strstr(str, "$Revision:")) != NULL && strchr(p1+1, '$') != NULL) { - if (sscanf(p1, "$Revision: %d.%d", &maj_build, &build) < 2) { - /* SvnRev also writes this keyword in its own generated file; read it - * back for partial updates - */ - cnt = sscanf(p1, "$Revision: %d%c", &build, &modchar); - if (cnt == 2 && modchar == 'M' && ismodified != NULL) - *ismodified = 1; - maj_build = 0; - } /* if */ - } else if ((p1 = strstr(str, "$Date:")) != NULL && strchr(p1+1, '$') != NULL) { - if (sscanf(p1, "$Date: %d-%d-%d", &year, &month, &day) < 3) - sscanf(p1, "$Date: %d/%d/%d", &year, &month, &day); - } else if (ismodified != NULL && *ismodified == 0 && fp_base != NULL) { - /* no keyword present, compare the lines for equivalence */ - *ismodified = strcmp(str, str_base) != 0; - } /* if */ - - if (maj_build) - *accum_build += build; /* RCS / CVS */ - else if (build > *max_build) - *max_build = build; /* Subversion */ - if (year > *max_year - || (year == *max_year && month > *max_month) - || (year == *max_year && month == *max_month && day > *max_day)) - { - *max_year = year; - *max_month = month; - *max_day = day; - } /* if */ - if (build > 0 && year > 0 && (fp_base == NULL || ismodified == NULL || *ismodified != 0)) - break; /* both build # and date found, not comparing or modification - * already found => no need to search further */ - - } /* while */ - fclose(fp); - if (fp_base != NULL) - fclose(fp_base); -} - -int main(int argc, char *argv[]) -{ - char *outname = NULL; - FILE *fp; - FILE *input_file; - char *input_file_name = NULL; - char *path_prefix = NULL; - int index; - int process_self = 0; - int verbose = 0; - int max_build, accum_build; - int max_year, max_month, max_day; - int ismodified, filemodified; - char prefix[MAX_SYMBOLLENGTH], suffix[MAX_SYMBOLLENGTH]; - char modified_suffix[2]; - int write_java = 0; /* flag for Java output, 0=.h output, 1=.java output */ - /* java package to put revision info in. - * REVIEW - I assume if you want Java output you will specify a package. */ - char *java_package = NULL; - - if (argc <= 1) - about(); - - /* collect the options */ - prefix[0] = '\0'; - suffix[0] = '\0'; - - for (index = 1; index < argc; index++) { - /* check for options */ - if (argv[index][0] == '-' -#if defined __WIN32__ || defined _Win32 || defined _WIN32 - || argv[index][0] == '/' -#endif - ) - { - switch (argv[index][1]) { - case 'f': { - int len; - char *ptr = strchr(&argv[index][2], '#'); - len = (ptr != NULL) ? (int)(ptr - &argv[index][2]) : (int)strlen(&argv[index][2]); - if (len >= MAX_SYMBOLLENGTH) - len = MAX_SYMBOLLENGTH - 1; - strncpy(prefix, &argv[index][2], len); - prefix[len] = '\0'; - ptr = (ptr != NULL) ? ptr + 1 : strchr(argv[index], '\0'); - len = (int)strlen(ptr); - if (len >= MAX_SYMBOLLENGTH) - len = MAX_SYMBOLLENGTH - 1; - strncpy(suffix, ptr, len); - suffix[len] = '\0'; - break; - } /* case */ - case 'i': - process_self = 1; - break; - case 'j': - write_java=1; - java_package = &argv[index][2]; - break; - case 'o': - outname = &argv[index][2]; - break; - case 'r': - input_file_name = &argv[index][2]; - break; - case 'p': - path_prefix = &argv[index][2]; - break; - case 'v': - verbose = 1; - break; - default: - fprintf(stderr, "Invalid option '%s'\n", argv[index]); - about(); - } /* switch */ - } /* if */ - } /* for */ - - if (outname == NULL) - outname = write_java ? "SvnRevision.java" : "uni_revision.h"; - if (!process_self && *outname != '\0') - remove(outname); - - /* phase 1: scan through all files and get the highest build number */ - - max_build = 0; - accum_build = 0; /* for RCS / CVS */ - max_year = max_month = max_day = 0; - ismodified = 0; - - if(input_file_name) { - input_file = fopen(input_file_name, "r"); - if (input_file != NULL) { - apr_dir_t *dir; - apr_finfo_t finfo; - apr_status_t rv; - apr_pool_t *pool; - char *file_path; - char dir_path[256]; /* line */ - int offset = 0; - if(path_prefix) - offset = sprintf(dir_path, "%s", path_prefix); - else - offset = sprintf(dir_path, "../../"); - - apr_initialize(); - apr_pool_create(&pool,NULL); - while (fgets(dir_path + offset, sizeof(dir_path) - offset, input_file) != NULL ) { /* read a line */ - size_t len = strlen(dir_path)-1; - if(dir_path[len] == '\n') - dir_path[len] = 0; - rv = apr_dir_open(&dir,dir_path,pool); - if(rv == APR_SUCCESS) { - while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { /* get next file */ - if(finfo.filetype != APR_REG) continue; - - apr_filepath_merge(&file_path,dir_path,finfo.name,0,pool); - - filemodified = 0; - if (strcasecmp(file_path, outname)!=0) - processfile(file_path, 0, &max_build, &accum_build, &max_year, &max_month, &max_day, &filemodified); - if (filemodified && verbose) - fprintf(stderr, "\tNotice: modified file '%s'\n", file_path); - ismodified = ismodified || filemodified; - } - apr_dir_close(dir); - } - else { - fprintf(stderr, "No such directory '%s'\n", dir_path); - } - } - fclose (input_file); - apr_pool_destroy(pool); - apr_terminate(); - } - else { - fprintf(stderr, "No such input file '%s'\n", input_file_name); - } - } - else { - for (index = 1; index < argc; index++) { - /* skip the options (already handled) */ - if (argv[index][0] == '-' -#if defined __WIN32__ || defined _Win32 || defined _WIN32 - || argv[index][0] == '/' -#endif - ) - continue; - - filemodified = 0; - if (strcasecmp(argv[index], outname)!=0) - processfile(argv[index], 0, &max_build, &accum_build, &max_year, &max_month, &max_day, &filemodified); - if (filemodified && verbose) - fprintf(stderr, "\tNotice: modified file '%s'\n", argv[index]); - ismodified = ismodified || filemodified; - } /* for */ - } - - /* also run over the existing header file, if any */ - if (process_self && *outname != '\0') - processfile(outname, 1, &max_build, &accum_build, &max_year, &max_month, &max_day, NULL/*&ismodified*/); - - if (accum_build > max_build) - max_build = accum_build; - modified_suffix[0] = ismodified ? 'M' : '\0'; - modified_suffix[1] = '\0'; - - /* phase 2: write a file with this highest build number */ - if (*outname == '\0') { - fp = stdout; - } else if ((fp = fopen(outname, "w")) == NULL) { - fprintf(stderr, "Failed to create output file '%s'\n", outname); - return 2; - } /* if */ - if (*outname != '\0') { - /* don't print the comments to stdout */ - fprintf(fp, "/* This file was generated by the \"svnrev\" utility\n" - " * (http://www.compuphase.com/svnrev.htm).\n" - " * You should not modify it manually, as it may be re-generated.\n" - " *\n" - " * $Revision: %d%s$\n" - " * $Date: %04d-%02d-%02d$\n" - " */\n\n", max_build, modified_suffix, max_year, max_month, max_day); - } /* if */ - - fprintf(fp, "#ifndef UNI_REVISION_H\n"); - fprintf(fp, "#define UNI_REVISION_H\n\n"); - fprintf(fp, "#define UNI_REVISION\t\t%d\n", max_build); - fprintf(fp, "#define UNI_REVISION_STRING\t\"%s%d%s%s\"\n", prefix, max_build, modified_suffix, suffix); - fprintf(fp, "#define UNI_REVISION_DATE\t\"%04d-%02d-%02d\"\n", max_year, max_month, max_day); - fprintf(fp, "#define UNI_REVISION_STAMP\t%04d%02d%02dL\n", max_year, max_month, max_day); - fprintf(fp, "#define UNI_REVISION_MODIFIED\t%d\n", ismodified); - fprintf(fp, "\n#endif /* UNI_REVISION_H */\n"); - - if (*outname != '\0') - fclose(fp); - - return 0; -} diff --git a/libs/unimrcp/build/svnrev/svnrev.input b/libs/unimrcp/build/svnrev/svnrev.input deleted file mode 100644 index 1f73eb847e..0000000000 --- a/libs/unimrcp/build/svnrev/svnrev.input +++ /dev/null @@ -1,32 +0,0 @@ -build -libs/apr-toolkit/include -libs/apr-toolkit/src -libs/mpf/include -libs/mpf/src -libs/mrcp/control/include -libs/mrcp/control/src -libs/mrcp/include -libs/mrcp/message/include -libs/mrcp/message/src -libs/mrcp/resources/include -libs/mrcp/resources/src -libs/mrcp-client/include -libs/mrcp-client/src -libs/mrcp-server/include -libs/mrcp-server/src -libs/mrcp-engine/include -libs/mrcp-engine/src -libs/mrcp-signaling/include -libs/mrcp-signaling/src -libs/mrcpv2-transport/include -libs/mrcpv2-transport/src -libs/uni-rtsp/include -libs/uni-rtsp/src -modules/mrcp-sofiasip/include -modules/mrcp-sofiasip/src -modules/mrcp-unirtsp/include -modules/mrcp-unirtsp/src -platforms/libunimrcp-client/include -platforms/libunimrcp-client/src -platforms/libunimrcp-server/include -platforms/libunimrcp-server/src \ No newline at end of file diff --git a/libs/unimrcp/build/svnrev/svnrev.vcproj b/libs/unimrcp/build/svnrev/svnrev.vcproj deleted file mode 100644 index 44259880b7..0000000000 --- a/libs/unimrcp/build/svnrev/svnrev.vcproj +++ /dev/null @@ -1,345 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/build/tools/prepare.2008.vcproj b/libs/unimrcp/build/tools/prepare.2008.vcproj deleted file mode 100644 index d19d002f7e..0000000000 --- a/libs/unimrcp/build/tools/prepare.2008.vcproj +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/build/tools/prepare.vcproj b/libs/unimrcp/build/tools/prepare.vcproj index 4fec72ee99..3b03c54a93 100644 --- a/libs/unimrcp/build/tools/prepare.vcproj +++ b/libs/unimrcp/build/tools/prepare.vcproj @@ -28,7 +28,7 @@ > + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {01D63BF5-7798-4746-852A-4B45229BB735} + prepare + Win32Proj + + + + Utility + Unicode + true + + + Utility + Unicode + + + Utility + Unicode + true + + + Utility + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + xcopy "$(AprDir)\$(Configuration)\libapr-1.dll" "$(SolutionDir)$(Configuration)\bin\" /Y +xcopy "$(AprUtilDir)\$(Configuration)\libaprutil-1.dll" "$(SolutionDir)$(Configuration)\bin\" /Y + +if exist "$(AprIconvDir)\$(Configuration)\libapriconv-1.dll" ( +xcopy "$(AprIconvDir)\$(Configuration)\libapriconv-1.dll" "$(SolutionDir)$(Configuration)\bin\" /Y +if exist "$(AprIconvDir)\$(Configuration)\iconv" ( +if not exist "$(SolutionDir)$(Configuration)\bin\iconv" mkdir "$(SolutionDir)$(Configuration)\bin\iconv" +xcopy "$(AprIconvDir)\$(Configuration)\iconv\*.so" "$(SolutionDir)$(Configuration)\bin\iconv\" /Y +) +) + +xcopy "$(SofiaDir)\win32\libsofia-sip-ua\$(Configuration)\libsofia_sip_ua.dll" "$(SolutionDir)$(Configuration)\bin\" /Y +xcopy "$(SofiaDir)\win32\pthread\$(Configuration)\pthreadVC2.dll" "$(SolutionDir)$(Configuration)\bin\" /Y + +if not exist "$(SolutionDir)$(Configuration)\conf" ( +xcopy "$(SolutionDir)conf\*.xml" "$(SolutionDir)$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\*.xsd" "$(SolutionDir)$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\client-profiles\*.xml" "$(SolutionDir)$(Configuration)\conf\client-profiles\" /Y +) + +if not exist "$(SolutionDir)$(Configuration)\data" xcopy "$(SolutionDir)data\*" "$(SolutionDir)$(Configuration)\data\" /Y +if not exist "$(SolutionDir)$(Configuration)\log" mkdir "$(SolutionDir)$(Configuration)\log\" +if not exist "$(SolutionDir)$(Configuration)\var" mkdir "$(SolutionDir)$(Configuration)\var\" + + + + + + xcopy "$(AprDir)\$(Platform)\$(Configuration)\libapr-1.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y +xcopy "$(AprUtilDir)\$(Platform)\$(Configuration)\libaprutil-1.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y + +if exist "$(AprIconvDir)\$(Platform)\$(Configuration)\libapriconv-1.dll" ( +xcopy "$(AprIconvDir)\$(Platform)\$(Configuration)\libapriconv-1.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y +if exist "$(AprIconvDir)\$(Platform)\$(Configuration)\iconv" ( +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\bin\iconv" mkdir "$(SolutionDir)$(Platform)\$(Configuration)\bin\iconv" +xcopy "$(AprIconvDir)\$(Platform)\$(Configuration)\iconv\*.so" "$(SolutionDir)$(Platform)\$(Configuration)\bin\iconv\" /Y +) +) + +xcopy "$(SofiaDir)\win32\libsofia-sip-ua\$(Platform)\$(Configuration)\libsofia_sip_ua.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y +xcopy "$(SofiaDir)\win32\pthread\$(Platform)\$(Configuration)\pthreadVC2.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y + +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\conf" ( +xcopy "$(SolutionDir)conf\*.xml" "$(SolutionDir)$(Platform)\$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\*.xsd" "$(SolutionDir)$(Platform)\$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\client-profiles\*.xml" "$(SolutionDir)$(Platform)\$(Configuration)\conf\client-profiles\" /Y +) + +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\data" xcopy "$(SolutionDir)data\*" "$(SolutionDir)$(Platform)\$(Configuration)\data\" /Y +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\log" mkdir "$(SolutionDir)$(Platform)\$(Configuration)\log\" +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\var" mkdir "$(SolutionDir)$(Platform)\$(Configuration)\var\" + + + + X64 + + + + + xcopy "$(AprDir)\$(Configuration)\libapr-1.dll" "$(SolutionDir)$(Configuration)\bin\" /Y +xcopy "$(AprUtilDir)\$(Configuration)\libaprutil-1.dll" "$(SolutionDir)$(Configuration)\bin\" /Y + +if exist "$(AprIconvDir)\$(Configuration)\libapriconv-1.dll" ( +xcopy "$(AprIconvDir)\$(Configuration)\libapriconv-1.dll" "$(SolutionDir)$(Configuration)\bin\" /Y +if exist "$(AprIconvDir)\$(Configuration)\iconv" ( +if not exist "$(SolutionDir)$(Configuration)\bin\iconv" mkdir "$(SolutionDir)$(Configuration)\bin\iconv" +xcopy "$(AprIconvDir)\$(Configuration)\iconv\*.so" "$(SolutionDir)$(Configuration)\bin\iconv\" /Y +) +) + +xcopy "$(SofiaDir)\win32\libsofia-sip-ua\$(Configuration)\libsofia_sip_ua.dll" "$(SolutionDir)$(Configuration)\bin\" /Y +xcopy "$(SofiaDir)\win32\pthread\$(Configuration)\pthreadVC2.dll" "$(SolutionDir)$(Configuration)\bin\" /Y + +if not exist "$(SolutionDir)$(Configuration)\conf" ( +xcopy "$(SolutionDir)conf\*.xml" "$(SolutionDir)$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\*.xsd" "$(SolutionDir)$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\client-profiles\*.xml" "$(SolutionDir)$(Configuration)\conf\client-profiles\" /Y +) + +if not exist "$(SolutionDir)$(Configuration)\data" xcopy "$(SolutionDir)data\*" "$(SolutionDir)$(Configuration)\data\" /Y +if not exist "$(SolutionDir)$(Configuration)\log" mkdir "$(SolutionDir)$(Configuration)\log\" +if not exist "$(SolutionDir)$(Configuration)\var" mkdir "$(SolutionDir)$(Configuration)\var\" + + + + + + xcopy "$(AprDir)\$(Platform)\$(Configuration)\libapr-1.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y +xcopy "$(AprUtilDir)\$(Platform)\$(Configuration)\libaprutil-1.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y + +if exist "$(AprIconvDir)\$(Platform)\$(Configuration)\libapriconv-1.dll" ( +xcopy "$(AprIconvDir)\$(Platform)\$(Configuration)\libapriconv-1.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y +if exist "$(AprIconvDir)\$(Platform)\$(Configuration)\iconv" ( +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\bin\iconv" mkdir "$(SolutionDir)$(Platform)\$(Configuration)\bin\iconv" +xcopy "$(AprIconvDir)\$(Platform)\$(Configuration)\iconv\*.so" "$(SolutionDir)$(Platform)\$(Configuration)\bin\iconv\" /Y +) +) + +xcopy "$(SofiaDir)\win32\libsofia-sip-ua\$(Platform)\$(Configuration)\libsofia_sip_ua.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y +xcopy "$(SofiaDir)\win32\pthread\$(Platform)\$(Configuration)\pthreadVC2.dll" "$(SolutionDir)$(Platform)\$(Configuration)\bin\" /Y + +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\conf" ( +xcopy "$(SolutionDir)conf\*.xml" "$(SolutionDir)$(Platform)\$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\*.xsd" "$(SolutionDir)$(Platform)\$(Configuration)\conf\" /Y +xcopy "$(SolutionDir)conf\client-profiles\*.xml" "$(SolutionDir)$(Platform)\$(Configuration)\conf\client-profiles\" /Y +) + +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\data" xcopy "$(SolutionDir)data\*" "$(SolutionDir)$(Platform)\$(Configuration)\data\" /Y +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\log" mkdir "$(SolutionDir)$(Platform)\$(Configuration)\log\" +if not exist "$(SolutionDir)$(Platform)\$(Configuration)\var" mkdir "$(SolutionDir)$(Platform)\$(Configuration)\var\" + + + + X64 + + + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/build/tools/preparesphinx.vcproj b/libs/unimrcp/build/tools/preparesphinx.vcproj deleted file mode 100644 index 1e274a4365..0000000000 --- a/libs/unimrcp/build/tools/preparesphinx.vcproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/build/tools/unimrcp_service.c b/libs/unimrcp/build/tools/unimrcp_service.c index c76459fa19..db2ed39bab 100644 --- a/libs/unimrcp/build/tools/unimrcp_service.c +++ b/libs/unimrcp/build/tools/unimrcp_service.c @@ -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,136 +13,241 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: unimrcp_service.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: unimrcp_service.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include #include +#include +#include #include "apt.h" #include "apt_pool.h" #define WIN_SERVICE_NAME "unimrcp" +/** UniMRCP service register command enumeration */ +typedef enum uni_service_register_e { + USR_NONE, USR_REGISTER, USR_UNREGISTER +} uni_service_register_e; + +/** UniMRCP service control command enumeration */ +typedef enum uni_service_control_e { + USC_NONE, USC_START, USC_STOP +} uni_service_control_e; + + +/** Display error message with Windows error code and description */ +static void winerror(const char *msg) +{ + char buf[128]; + DWORD err = GetLastError(); + int ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + buf, sizeof(buf), NULL); + printf("%s: %lu %.*s\n", msg, err, ret, buf); +} /** Register/install service in SCM */ -static apt_bool_t uni_service_register(const char *root_dir_path, apr_pool_t *pool) +static apt_bool_t uni_service_register(const char *root_dir_path, apr_pool_t *pool, + const char *name, + apt_bool_t autostart, + unsigned long recover, + int log_priority, + const char *disp_name, + const char *description) { - char *bin_path; + apr_status_t status; + char buf[4096]; + static const size_t len = sizeof(buf); + size_t pos = 0; + char *root_dir; SERVICE_DESCRIPTION desc; SC_HANDLE sch_service; - SC_HANDLE sch_manager = OpenSCManager(0,0,SC_MANAGER_ALL_ACCESS); - if(!sch_manager) { - printf("Failed to Open SCManager %d\n", GetLastError()); + SC_HANDLE sch_manager; + + /* Normalize root directory path and make it absolute */ + status = apr_filepath_merge(&root_dir, NULL, root_dir_path, + APR_FILEPATH_NOTRELATIVE | APR_FILEPATH_NATIVE | APR_FILEPATH_TRUENAME, pool); + if (status != APR_SUCCESS) { + printf("Error making root directory absolute: %d %.512s\n", status, + apr_strerror(status, buf, 512)); return FALSE; } + buf[pos++] = '"'; + pos = apr_cpystrn(buf + pos, root_dir, len - pos) - buf; + if ((buf[pos - 1] != '\\') && (pos < len)) + /* Add trailing backslash */ + buf[pos++] = '\\'; + pos = apr_cpystrn(buf + pos, "bin\\unimrcpserver.exe\" --service -o 2", len - pos) - buf; + if (log_priority >= 0) { + pos = apr_cpystrn(buf + pos, " -l ", len - pos) - buf; + if (pos < len - 34) + pos += strlen(itoa(log_priority, buf + pos, 10)); + } + if (name) { + pos = apr_cpystrn(buf + pos, " --name \"", len - pos) - buf; + pos = apr_cpystrn(buf + pos, name, len - pos) - buf; + if ((buf[pos - 1] == '\\') && (pos < len)) + /* `\"' might be misinterpreted as escape, so replace `\' with `\\' */ + buf[pos++] = '\\'; + if (pos < len) + buf[pos++] = '"'; + } + pos = apr_cpystrn(buf + pos, " --root-dir \"", len - pos) - buf; + pos = apr_cpystrn(buf + pos, root_dir, len - pos) - buf; + if ((buf[pos - 1] == '\\') && (pos < len)) + /* `\"' might be misinterpreted as escape, so replace `\' with `\\' */ + buf[pos++] = '\\'; + if (pos < len) + buf[pos++] = '"'; + if (pos < len) + buf[pos] = 0; + else { + puts("Service Command Too Long"); + return FALSE; + } + if (!disp_name || !*disp_name) { + if (name) + disp_name = apr_pstrcat(pool, name, " ", "UniMRCP Server", NULL); + else + disp_name = "UniMRCP Server"; + } + if (!description || !*description) + description = "Launches UniMRCP Server"; - bin_path = apr_psprintf(pool,"%s\\bin\\unimrcpserver.exe --service --root-dir \"%s\" -o 2", - root_dir_path, - root_dir_path); + sch_manager = OpenSCManager(0,0,SC_MANAGER_ALL_ACCESS); + if(!sch_manager) { + winerror("Failed to Open SCManager"); + return FALSE; + } sch_service = CreateService( sch_manager, - WIN_SERVICE_NAME, - "UniMRCP Server", + name ? name : WIN_SERVICE_NAME, + disp_name, GENERIC_EXECUTE | SERVICE_CHANGE_CONFIG, SERVICE_WIN32_OWN_PROCESS, - SERVICE_DEMAND_START, + autostart ? SERVICE_AUTO_START : SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, - bin_path,0,0,0,0,0); + buf,0,0,0,0,0); if(!sch_service) { - printf("Failed to Create Service %d\n", GetLastError()); + winerror("Failed to Create Service"); CloseServiceHandle(sch_manager); return FALSE; } - desc.lpDescription = "Launches UniMRCP Server"; + desc.lpDescription = (char *) description; if(!ChangeServiceConfig2(sch_service,SERVICE_CONFIG_DESCRIPTION,&desc)) { - printf("Failed to Set Service Description %d\n", GetLastError()); + winerror("Failed to Set Service Description"); + } + + if (recover) { + SERVICE_FAILURE_ACTIONS sfa; + SC_ACTION action; + sfa.dwResetPeriod = 0; + sfa.lpCommand = ""; + sfa.lpRebootMsg = ""; + sfa.cActions = 1; + sfa.lpsaActions = &action; + action.Delay = recover * 1000; + action.Type = SC_ACTION_RESTART; + if (!ChangeServiceConfig2(sch_service,SERVICE_CONFIG_FAILURE_ACTIONS,&sfa)) { + winerror("Failed to Set Service Restart on Failure"); + } } CloseServiceHandle(sch_service); CloseServiceHandle(sch_manager); + printf("UniMRCP service %s registered\n", name ? name : WIN_SERVICE_NAME); return TRUE; } /** Unregister/uninstall service from SCM */ -static apt_bool_t uni_service_unregister() +static apt_bool_t uni_service_unregister(const char *name) { apt_bool_t status = TRUE; SERVICE_STATUS ss_status; SC_HANDLE sch_service; SC_HANDLE sch_manager = OpenSCManager(0,0,SC_MANAGER_ALL_ACCESS); + if (!name) name = WIN_SERVICE_NAME; if(!sch_manager) { - printf("Failed to Open SCManager %d\n", GetLastError()); + winerror("Failed to Open SCManager"); return FALSE; } - sch_service = OpenService(sch_manager,WIN_SERVICE_NAME,DELETE|SERVICE_STOP); + sch_service = OpenService(sch_manager,name,DELETE|SERVICE_STOP); if(!sch_service) { - printf("Failed to Open Service %d\n", GetLastError()); + winerror("Failed to Open Service"); CloseServiceHandle(sch_manager); return FALSE; } ControlService(sch_service,SERVICE_CONTROL_STOP,&ss_status); if(!DeleteService(sch_service)) { - printf("Failed to Delete Service %d\n", GetLastError()); + winerror("Failed to Delete Service"); status = FALSE; - } + } else + printf("UniMRCP service %s unregistered\n", name); CloseServiceHandle(sch_service); CloseServiceHandle(sch_manager); return status; } /** Start service */ -static apt_bool_t uni_service_start() +static apt_bool_t uni_service_start(const char *name) { apt_bool_t status = TRUE; SC_HANDLE sch_service; SC_HANDLE sch_manager = OpenSCManager(0,0,SC_MANAGER_ALL_ACCESS); + if (!name) name = WIN_SERVICE_NAME; if(!sch_manager) { - printf("Failed to Open SCManager %d\n", GetLastError()); + winerror("Failed to Open SCManager"); return FALSE; } - sch_service = OpenService(sch_manager,WIN_SERVICE_NAME,SERVICE_START); + sch_service = OpenService(sch_manager,name,SERVICE_START); if(!sch_service) { - printf("Failed to Open Service %d\n", GetLastError()); + winerror("Failed to Open Service"); CloseServiceHandle(sch_manager); return FALSE; } if(!StartService(sch_service,0,NULL)) { - printf("Failed to Start Service %d\n", GetLastError()); + winerror("Failed to Start Service"); status = FALSE; - } + } else + printf("UniMRCP service %s started\n", name); CloseServiceHandle(sch_service); CloseServiceHandle(sch_manager); return status; } /** Stop service */ -static apt_bool_t uni_service_stop() +static apt_bool_t uni_service_stop(const char *name) { apt_bool_t status = TRUE; SERVICE_STATUS ss_status; SC_HANDLE sch_service; SC_HANDLE sch_manager = OpenSCManager(0,0,SC_MANAGER_ALL_ACCESS); + if (!name) name = WIN_SERVICE_NAME; if(!sch_manager) { - printf("Failed to Open SCManager %d\n", GetLastError()); + winerror("Failed to Open SCManager"); return FALSE; } - sch_service = OpenService(sch_manager,WIN_SERVICE_NAME,SERVICE_STOP); + sch_service = OpenService(sch_manager,name,SERVICE_STOP); if(!sch_service) { - printf("Failed to Open Service %d\n", GetLastError()); + winerror("Failed to Open Service"); CloseServiceHandle(sch_manager); return FALSE; } if(!ControlService(sch_service,SERVICE_CONTROL_STOP,&ss_status)) { - printf("Failed to Stop Service %d\n", GetLastError()); + winerror("Failed to Stop Service"); status = FALSE; - } + } else + printf("UniMRCP service %s stopped\n", name); CloseServiceHandle(sch_service); CloseServiceHandle(sch_manager); @@ -152,6 +257,8 @@ static apt_bool_t uni_service_stop() static void usage() { + static apt_bool_t written = FALSE; + if (written) return; printf( "\n" "Usage:\n" @@ -168,8 +275,21 @@ static void usage() "\n" " -t [--stop] : Stop the Windows service.\n" "\n" + " -n [--name] svcname : Service name (default: unimrcp)\n" + "\n" + " -a [--autostart] : Start service after boot-up\n" + "\n" + " -f [--fail-restart] n : If crashed, restart after n secs\n" + "\n" + " -l [--log-prio] priority: Set the log priority.\n" + " (0-emergency, ..., 7-debug)\n" + " -p [--disp-name] title : Set service display name\n" + " (default: [svcname] UniMRCP Server)\n" + " -c [--description] desc : Set service description\n" + " (default: Launches UniMRCP Server)\n" " -h [--help] : Show the help.\n" "\n"); + written = TRUE; } int main(int argc, const char * const *argv) @@ -177,28 +297,44 @@ int main(int argc, const char * const *argv) apr_pool_t *pool; apr_status_t rv; apr_getopt_t *opt; + apt_bool_t ret = TRUE; + uni_service_register_e reg = USR_NONE; + uni_service_control_e control = USC_NONE; + const char *root_dir = ".."; + const char *name = NULL; + apt_bool_t autostart = FALSE; + unsigned long recover = 0; + int log_priority = -1; + const char *disp_name = NULL; + const char *description = NULL; static const apr_getopt_option_t opt_option[] = { /* long-option, short-option, has-arg flag, description */ - { "register", 'r', TRUE, "register service" }, /* -r or --register arg */ - { "unregister", 'u', FALSE, "unregister service" },/* -u or --unregister */ - { "start", 's', FALSE, "start service" }, /* -s or --start */ - { "stop", 't', FALSE, "stop service" }, /* -t or --stop */ - { "help", 'h', FALSE, "show help" }, /* -h or --help */ - { NULL, 0, 0, NULL }, /* end */ + { "register", 'r', TRUE, "register service" }, /* -r or --register arg */ + { "unregister", 'u', FALSE, "unregister service" }, /* -u or --unregister */ + { "start", 's', FALSE, "start service" }, /* -s or --start */ + { "stop", 't', FALSE, "stop service" }, /* -t or --stop */ + { "name", 'n', TRUE, "service name" }, /* -n or --name arg */ + { "autostart", 'a', FALSE, "start automatically" },/* -a or --autostart */ + { "fail-restart",'f', TRUE, "restart if fails" }, /* -f or --fail-restart arg */ + { "log-prio", 'l', TRUE, "log priority" }, /* -l arg or --log-prio arg */ + { "disp-name", 'p', TRUE, "display name" }, /* -p arg or --disp-name arg */ + { "description", 'c', TRUE, "description" }, /* -c arg or --description arg */ + { "help", 'h', FALSE, "show help" }, /* -h or --help */ + { NULL, 0, 0, NULL }, /* end */ }; /* APR global initialization */ if(apr_initialize() != APR_SUCCESS) { apr_terminate(); - return 0; + return 1; } /* create APR pool */ pool = apt_pool_create(); if(!pool) { apr_terminate(); - return 0; + return 1; } rv = apr_getopt_init(&opt, pool , argc, argv); @@ -208,30 +344,103 @@ int main(int argc, const char * const *argv) while((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) { switch(optch) { case 'r': - uni_service_register(optarg,pool); + if ((reg == USR_NONE) || (reg == USR_REGISTER)) { + reg = USR_REGISTER; + root_dir = optarg; + } else { + puts("Incosistent arguments"); + ret = FALSE; + } break; case 'u': - uni_service_unregister(); + if ((reg == USR_NONE) || (reg == USR_UNREGISTER)) + reg = USR_UNREGISTER; + else { + puts("Incosistent arguments"); + ret = FALSE; + } break; case 's': - uni_service_start(); + if ((control == USC_NONE) || (control == USC_START)) + control = USC_START; + else { + puts("Incosistent arguments"); + ret = FALSE; + } break; case 't': - uni_service_stop(); + if ((control == USC_NONE) || (control == USC_STOP)) + control = USC_STOP; + else { + puts("Incosistent arguments"); + ret = FALSE; + } + break; + case 'n': + name = optarg; + break; + case 'a': + autostart = TRUE; + break; + case 'f': + if (sscanf(optarg, "%lu", &recover) != 1) { + puts("Invalid value for param --fail-restart"); + ret = FALSE; + } + break; + case 'l': + if ((sscanf(optarg, "%d", &log_priority) != 1) || + (log_priority < 0) || (log_priority > 7)) + { + puts("Invalid value for param --log-prio"); + ret = FALSE; + } + break; + case 'p': + disp_name = optarg; + break; + case 'c': + description = optarg; break; case 'h': usage(); break; } + if (!ret) break; } - if(rv != APR_EOF) { + if (ret && + (((reg == USR_REGISTER) && (control == USC_STOP)) || + ((reg == USR_UNREGISTER) && (control == USC_START)))) { + ret = FALSE; + puts("Inconsistent arguments"); + } + if((rv != APR_EOF) || !ret || (!reg && !control)) { + ret = FALSE; usage(); } } + while (ret) { /* No problem so far */ + if (reg == USR_REGISTER) + ret = uni_service_register(root_dir, pool, name, autostart, recover, log_priority, disp_name, description); + if (!ret) break; + + if (control == USC_START) + ret = uni_service_start(name); + if (!ret) break; + + if (control == USC_STOP) + ret = uni_service_stop(name); + /* Do not break here, stop failure should not matter before unregistration */ + + if (reg == USR_UNREGISTER) + ret = uni_service_unregister(name); + break; + } + /* destroy APR pool */ apr_pool_destroy(pool); /* APR global termination */ apr_terminate(); - return 0; + return ret ? 0 : 1; } diff --git a/libs/unimrcp/build/tools/unimrcpservice.2008.vcproj b/libs/unimrcp/build/tools/unimrcpservice.2008.vcproj deleted file mode 100644 index 2ae65f7c05..0000000000 --- a/libs/unimrcp/build/tools/unimrcpservice.2008.vcproj +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/build/tools/unimrcpservice.rc b/libs/unimrcp/build/tools/unimrcpservice.rc new file mode 100644 index 0000000000..a9cebe94dc --- /dev/null +++ b/libs/unimrcp/build/tools/unimrcpservice.rc @@ -0,0 +1,39 @@ +#include "uni_version.h" + +1 VERSIONINFO + FILEVERSION UNI_VERSION_STRING_CSV,0 + PRODUCTVERSION UNI_VERSION_STRING_CSV,0 + FILEFLAGSMASK 0x3fL +#if defined(_DEBUG) + FILEFLAGS 0x01L +#else + FILEFLAGS 0x00L +#endif +#if defined(WINNT) || defined(WIN64) + FILEOS 0x40004L +#else + FILEOS 0x4L +#endif + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", UNI_LICENSE "\0" + VALUE "CompanyName", "UniMRCP\0" + VALUE "FileDescription", "UniMRCP Service Manager\0" + VALUE "FileVersion", UNI_VERSION_STRING "\0" + VALUE "InternalName", "unimrcpservice" "\0" + VALUE "LegalCopyright", UNI_COPYRIGHT "\0" + VALUE "OriginalFilename", "unimrcpservice.exe" "\0" + VALUE "ProductName", "UniMRCP Project\0" + VALUE "ProductVersion", UNI_VERSION_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/libs/unimrcp/build/tools/unimrcpservice.vcproj b/libs/unimrcp/build/tools/unimrcpservice.vcproj index 1c0b13840f..fec552b155 100644 --- a/libs/unimrcp/build/tools/unimrcpservice.vcproj +++ b/libs/unimrcp/build/tools/unimrcpservice.vcproj @@ -284,6 +284,42 @@ > + + + + + + + + + + + + + + diff --git a/libs/unimrcp/build/tools/unimrcpservice.vcxproj b/libs/unimrcp/build/tools/unimrcpservice.vcxproj new file mode 100644 index 0000000000..f8bb3a3404 --- /dev/null +++ b/libs/unimrcp/build/tools/unimrcpservice.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4714EF49-BFD5-4B22-95F7-95A07F1EAC25} + unimrcpservice + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + RequireAdministrator + + + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + RequireAdministrator + + + + + X64 + + + ProgramDatabase + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + RequireAdministrator + + + + + X64 + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + RequireAdministrator + + + + + + + + {13deeca0-bdd4-4744-a1a2-8eb0a44df3d2} + false + + + + + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/build/tools/unimrcpservice.vcxproj.filters b/libs/unimrcp/build/tools/unimrcpservice.vcxproj.filters new file mode 100644 index 0000000000..8a04533143 --- /dev/null +++ b/libs/unimrcp/build/tools/unimrcpservice.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/build/uni_revision.h b/libs/unimrcp/build/uni_revision.h new file mode 100644 index 0000000000..b7680b88cf --- /dev/null +++ b/libs/unimrcp/build/uni_revision.h @@ -0,0 +1,43 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNI_REVISION_H +#define UNI_REVISION_H + +/** + * @file uni_revision.h + * @brief UniMRCP Revision + * + * This file contains the revision base number and other relevant information. + */ + +/** Revision base number. */ +#define UNI_REVISION 2208 + +/** Revision base string. */ +#define UNI_REVISION_STRING "2208" + +/** Revision base date. */ +#define UNI_REVISION_DATE "2014-10-31" + +/** Revision base stamp. */ +#define UNI_REVISION_STAMP 20141031L + + +/** Check at compile time if the revision base number is at least a certain level. */ +#define UNI_REVISION_AT_LEAST(rev) ((rev) < UNI_REVISION) + +#endif /* UNI_REVISION_H */ diff --git a/libs/unimrcp/build/uni_version.h b/libs/unimrcp/build/uni_version.h index 32e81b1b61..2e0edb9c30 100644 --- a/libs/unimrcp/build/uni_version.h +++ b/libs/unimrcp/build/uni_version.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: uni_version.h 1724 2010-06-02 18:42:20Z achaloyan $ + * $Id: uni_version.h 2139 2014-07-07 05:06:19Z achaloyan@gmail.com $ */ #ifndef UNI_VERSION_H @@ -21,11 +21,11 @@ /** * @file uni_version.h - * @brief UniMRCP Version Numbering + * @brief UniMRCP Version * - * UniMRCP version numbering is derived from APR project specified in: + * UniMRCP uses a version numbering scheme derived from the APR project. * - * http://apr.apache.org/versioning.html + * APR's Version Numbering */ /** major version @@ -37,60 +37,64 @@ /** minor version * Minor API changes that do not cause binary compatibility problems. - * Reset to 0 when upgrading UNI_MAJOR_VERSION + * Reset to 0 when upgrading UNI_MAJOR_VERSION. */ -#define UNI_MINOR_VERSION 0 +#define UNI_MINOR_VERSION 2 /** patch level * The Patch Level never includes API changes, simply bug fixes. - * Reset to 0 when upgrading UNI_MINOR_VERSION + * Reset to 0 when upgrading UNI_MINOR_VERSION. */ #define UNI_PATCH_VERSION 0 -/** - * Check at compile time if the UNI version is at least a certain - * level. - */ +/** Check at compile time if the version of UniMRCP is at least a certain level. */ #define UNI_VERSION_AT_LEAST(major,minor,patch) \ (((major) < UNI_MAJOR_VERSION) \ || ((major) == UNI_MAJOR_VERSION && (minor) < UNI_MINOR_VERSION) \ || ((major) == UNI_MAJOR_VERSION && (minor) == UNI_MINOR_VERSION && (patch) <= UNI_PATCH_VERSION)) - -/** Properly quote a value as a string in the C preprocessor */ +/** Properly quote a value as a string in the C preprocessor. */ #define UNI_STRINGIFY(n) UNI_STRINGIFY_HELPER(n) -/** Helper macro for UNI_STRINGIFY */ +/** Helper macro for UNI_STRINGIFY. */ #define UNI_STRINGIFY_HELPER(n) #n -/** The formatted string of UniMRCP's version */ +/** The formatted string of UniMRCP's version. */ #define UNI_VERSION_STRING \ UNI_STRINGIFY(UNI_MAJOR_VERSION) "." \ UNI_STRINGIFY(UNI_MINOR_VERSION) "." \ UNI_STRINGIFY(UNI_PATCH_VERSION) /** An alternative formatted string of UniMRCP's version - macro for Win32 .rc files using numeric csv representation */ + macro for Win32 .rc files using numeric CSV representation. */ #define UNI_VERSION_STRING_CSV UNI_MAJOR_VERSION ##, \ ##UNI_MINOR_VERSION ##, \ ##UNI_PATCH_VERSION -/** The Copyright */ -#define UNI_COPYRIGHT "Copyright 2008-2010 Arsen Chaloyan" +/** The Copyright. */ +#define UNI_COPYRIGHT "Copyright 2008-2014 Arsen Chaloyan" -/** The License */ +/* + * Use the brief description of the license for Win32 .rc files; + * otherwise, use the full description. + */ +#if defined(APSTUDIO_INVOKED) || defined(RC_INVOKED) +/** The License (brief description). */ +#define UNI_LICENSE "The Apache License, Version 2.0" +#else +/** The License (full description). */ #define UNI_LICENSE \ - "Licensed under the Apache License, Version 2.0 (the ""License"");" \ - "you may not use this file except in compliance with the License." \ - "You may obtain a copy of the License at" \ - "" \ - " http://www.apache.org/licenses/LICENSE-2.0" \ - "" \ - "Unless required by applicable law or agreed to in writing, software" \ - "distributed under the License is distributed on an ""AS IS"" BASIS," \ - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." \ - "See the License for the specific language governing permissions and" \ - "limitations under the License." - + " * Licensed under the Apache License, Version 2.0 (the ""License"");\n" \ + " * you may not use this file except in compliance with the License.\n" \ + " * You may obtain a copy of the License at\n" \ + " * \n" \ + " * http://www.apache.org/licenses/LICENSE-2.0 \n" \ + " * \n" \ + " * Unless required by applicable law or agreed to in writing, software\n" \ + " * distributed under the License is distributed on an ""AS IS"" BASIS,\n" \ + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" \ + " * See the License for the specific language governing permissions and\n" \ + " * limitations under the License.\n" +#endif /* APSTUDIO_INVOKED || RC_INVOKED */ #endif /* UNI_VERSION_H */ diff --git a/libs/unimrcp/build/vsprops/flite.vsprops b/libs/unimrcp/build/vsprops/flite.vsprops deleted file mode 100644 index 411cd4f80a..0000000000 --- a/libs/unimrcp/build/vsprops/flite.vsprops +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/libs/unimrcp/build/vsprops/pocketsphinx.vsprops b/libs/unimrcp/build/vsprops/pocketsphinx.vsprops deleted file mode 100644 index 52e284bd8f..0000000000 --- a/libs/unimrcp/build/vsprops/pocketsphinx.vsprops +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - diff --git a/libs/unimrcp/build/vsprops/sofiasip.vsprops b/libs/unimrcp/build/vsprops/sofiasip.vsprops index d9a5ad8fe2..2b5b65653b 100644 --- a/libs/unimrcp/build/vsprops/sofiasip.vsprops +++ b/libs/unimrcp/build/vsprops/sofiasip.vsprops @@ -7,7 +7,7 @@ > + + + + 1 50 - 200 + 600 + 1 20 PCMU PCMA L16/96/8000 telephone-event/101/8000 diff --git a/libs/unimrcp/conf/dirlayout.xml b/libs/unimrcp/conf/dirlayout.xml new file mode 100644 index 0000000000..45df55ba7e --- /dev/null +++ b/libs/unimrcp/conf/dirlayout.xml @@ -0,0 +1,26 @@ + + + + + conf + plugin + log + data + var + diff --git a/libs/unimrcp/conf/unimrcpclient.xml b/libs/unimrcp/conf/unimrcpclient.xml index ec44e2d058..cc23b9bc03 100644 --- a/libs/unimrcp/conf/unimrcpclient.xml +++ b/libs/unimrcp/conf/unimrcpclient.xml @@ -5,11 +5,17 @@ version="1.0" subfolder="client-profiles"> - + + + + + + + @@ -38,6 +44,8 @@ + + @@ -77,8 +85,10 @@ + 1 50 - 200 + 600 + 1 20 PCMU PCMA L16/96/8000 telephone-event/101/8000 diff --git a/libs/unimrcp/conf/unimrcpclient.xsd b/libs/unimrcp/conf/unimrcpclient.xsd index 349cae4252..b8e53bbf1f 100644 --- a/libs/unimrcp/conf/unimrcpclient.xsd +++ b/libs/unimrcp/conf/unimrcpclient.xsd @@ -67,6 +67,8 @@ + + @@ -191,8 +193,10 @@ + + @@ -258,6 +262,13 @@ + + + + + + + diff --git a/libs/unimrcp/conf/unimrcpserver.xml b/libs/unimrcp/conf/unimrcpserver.xml index 29189a8d03..b431acf313 100644 --- a/libs/unimrcp/conf/unimrcpserver.xml +++ b/libs/unimrcp/conf/unimrcpserver.xml @@ -2,11 +2,17 @@ - + + + + + + + @@ -35,6 +41,8 @@ + + @@ -85,8 +93,6 @@ - - @@ -105,8 +111,10 @@ + 1 50 - 200 + 600 + 1 20 PCMU PCMA L16/96/8000 telephone-event/101/8000 diff --git a/libs/unimrcp/conf/unimrcpserver.xsd b/libs/unimrcp/conf/unimrcpserver.xsd index 920e5072f8..f8222c84d5 100644 --- a/libs/unimrcp/conf/unimrcpserver.xsd +++ b/libs/unimrcp/conf/unimrcpserver.xsd @@ -1,266 +1,277 @@ - - - UniMRCP server document - - - - - - Generic properties - - - - - - - - - - - - - - - - - - - Common components - - - - - - Factory of MRCP resources - - - - - - - - - - - - - - - SIP signaling agent - - - - - - - - - - - - - - - - - - - - - - - RTSP signaling agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MRCPv2 connection agent - - - - - - - - - - - - - - - - - Media processing engine - - - - - - - - - - - - Factory of RTP terminations - - - - - - - - - - - - - - - Factory of plugins (MRCP engines) - - - - - - - - - - - - - - - - - - - - - - - - - - - - Settings - - - - - - RTP settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Profiles - - - - - - MRCPv2 profile - - - - - - - - - - - - - - - - MRCPv1 profile - - - - - - - - - - - - - - - - - - - - - + + + UniMRCP server document + + + + + + Generic properties + + + + + + + + + + + + + + + + + + + Common components + + + + + + Factory of MRCP resources + + + + + + + + + + + + + + + SIP signaling agent + + + + + + + + + + + + + + + + + + + + + + + + + RTSP signaling agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MRCPv2 connection agent + + + + + + + + + + + + + + + + + Media processing engine + + + + + + + + + + + + Factory of RTP terminations + + + + + + + + + + + + + + + Factory of plugins (MRCP engines) + + + + + + + + + + + + + + + + + + + + + + + + + + + + Settings + + + + + + RTP settings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Profiles + + + + + + MRCPv2 profile + + + + + + + + + + + + + + + + MRCPv1 profile + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/config.layout b/libs/unimrcp/config.layout new file mode 100644 index 0000000000..1d3472c1e9 --- /dev/null +++ b/libs/unimrcp/config.layout @@ -0,0 +1,26 @@ +## +## config.layout -- Pre-defined Installation Path Layouts +## +## Hints: +## - layouts can be loaded with configure's --enable-layout=ID option +## - when no --enable-layout option is given, the default layout is `classic' + +# Classical UniMRCP path layout. + + prefix: /usr/local/unimrcp + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/bin + libdir: ${exec_prefix}/lib + libexecdir: ${exec_prefix}/modules + mandir: ${prefix}/man + sysconfdir: ${prefix}/conf + confdir: ${prefix}/conf + datadir: ${prefix}/data + plugindir: ${exec_prefix}/plugin + logdir: ${exec_prefix}/log + vardir: ${exec_prefix}/var + installbuilddir: ${exec_prefix}/build + includedir: ${prefix}/include + localstatedir: ${prefix} + diff --git a/libs/unimrcp/configure.ac b/libs/unimrcp/configure.ac index e59de1e3c8..ac1eacf3af 100644 --- a/libs/unimrcp/configure.ac +++ b/libs/unimrcp/configure.ac @@ -1,34 +1,72 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. +dnl +dnl Autoconf configuration file for UniMRCP. +dnl +dnl Use ./bootstrap to produce a configure script. +dnl -AC_PREREQ(2.57) +AC_PREREQ(2.59) -AC_INIT([unimrcp],[1.0.0]) +AC_INIT([unimrcp],[1.2.0]) AC_CONFIG_AUX_DIR([build]) AC_CONFIG_MACRO_DIR([build/acmacros]) + +dnl Set ac_macro_dir variable manually for autoconf 2.61 and above. +ac_macro_dir="build/acmacros" + +AC_SUBST(ac_aux_dir) +AC_SUBST(ac_macro_dir) + +dnl Include m4 macros for libtool 2. +sinclude(build/acmacros/libtool.m4) +sinclude(build/acmacros/ltoptions.m4) +sinclude(build/acmacros/ltsugar.m4) +sinclude(build/acmacros/ltversion.m4) +sinclude(build/acmacros/lt~obsolete.m4) + AC_PREFIX_DEFAULT(/usr/local/unimrcp) -plugindir='${prefix}/plugin' -confdir='${prefix}/conf' -logdir='${prefix}/log' -datadir='${prefix}/data' +dnl Define the directory layout. +APR_ENABLE_LAYOUT(classic, [plugindir logdir vardir]) +AC_SUBST(plugindir) +AC_SUBST(logdir) +AC_SUBST(vardir) -AM_INIT_AUTOMAKE(foreign) +dnl Reparse the configure arguments. +APR_PARSE_ARGUMENTS -# Set default language +dnl Generate ./config.nice to reuse ./configure command-line. +APR_CONFIG_NICE(config.nice) + +AM_INIT_AUTOMAKE([no-define nostdinc foreign subdir-objects]) + +dnl Enable silent build rules available since automake 1.11. +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +dnl Set default language. AC_LANG_C AC_PROG_CC AC_PROG_CXX +AM_PROG_CC_C_O AC_PROG_INSTALL -# Skip detection of Fortran +dnl Skip detection of Fortran. m4_undefine([AC_PROG_F77]) m4_defun([AC_PROG_F77],[]) AC_PROG_LIBTOOL -# Get version information +dnl Do not use autoconf generated compiler DEFS. +rm confdefs.h +touch confdefs.h + +dnl Check for C compiler vendor. +AX_COMPILER_VENDOR + +dnl Search for pkg-config. +AC_PATH_PROG(PKG_CONFIG, pkg-config) + +dnl Get version information. get_version="$srcdir/build/get-version.sh" version_hdr="$srcdir/build/uni_version.h" plugin_version_hdr="$srcdir/libs/mrcp-engine/include/mrcp_engine_plugin.h" @@ -42,59 +80,111 @@ AC_SUBST(PLUGIN_LT_VERSION) echo "UniMRCP Version: ${UNI_DOTTED_VERSION}" -# Absolute source/build directory -unimrcp_srcdir=`(cd $srcdir && pwd)` -unimrcp_builddir=`pwd` -AC_SUBST(unimrcp_srcdir) -AC_SUBST(unimrcp_builddir) - -# Check APR +dnl Check for the APR and APR-util libraries. UNIMRCP_CHECK_APR -UNIMRCP_CHECK_APU - -# Check SOFIA +dnl Check for the Sofia-SIP library. UNIMRCP_CHECK_SOFIA +dnl Enable inter-library dependencies. +AC_ARG_ENABLE(interlib-deps, + [AC_HELP_STRING([--disable-interlib-deps ],[disable inter-library dependencies (might break builds)])], + [enable_interlib_deps="$enableval"], + [enable_interlib_deps="yes"]) +AC_MSG_NOTICE([enable inter-library dependencies: $enable_interlib_deps]) +if test "${enable_interlib_deps}" == "yes"; then + link_all_deplibs=yes + link_all_deplibs_CXX=yes +else + link_all_deplibs=no + link_all_deplibs_CXX=no +fi -AC_SUBST(ac_aux_dir) -AC_SUBST(ac_macro_dir) -AC_SUBST(plugindir) -AC_SUBST(confdir) -AC_SUBST(logdir) - -AC_DEFUN([AX_COMPILER_VENDOR], -[ -AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown - # note: don't check for gcc first since some other compilers define __GNUC__ - for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do - vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ -#if !($vencpp) - thisisanerror; -#endif -])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break]) - done - ]) -]) - -AX_COMPILER_VENDOR - -#Enable maintainer mode +dnl Enable maintainer mode. AC_ARG_ENABLE(maintainer-mode, [AC_HELP_STRING([--enable-maintainer-mode ],[turn on debugging and compile time warnings])], [enable_maintainer_mode="$enableval"], [enable_maintainer_mode="no"]) +AC_MSG_NOTICE([enable maintainer mode: $enable_maintainer_mode]) if test "${enable_maintainer_mode}" != "no"; then - CFLAGS="$CFLAGS -g" + APR_ADDTO(CFLAGS,-g) if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then - CFLAGS="$CFLAGS -Wall -Werror" + APR_ADDTO(CFLAGS,-Wall -Werror) fi fi -#Enable test suites +dnl UniMRCP client library. +AC_ARG_ENABLE(client-lib, + [AC_HELP_STRING([--disable-client-lib ],[exclude unimrcpclient lib from build])], + [enable_client_lib="$enableval"], + [enable_client_lib="yes"]) + +AM_CONDITIONAL([UNIMRCP_CLIENT_LIB],[test "${enable_client_lib}" = "yes"]) + +dnl Sample UniMRCP client application in C. +AC_ARG_ENABLE(client-app, + [AC_HELP_STRING([--disable-client-app ],[exclude sample unimrcpclient app from build])], + [enable_client_app="$enableval"], + [enable_client_app="yes"]) + +AM_CONDITIONAL([UNIMRCP_CLIENT_APP],[test "${enable_client_lib}" = "yes" && test "${enable_client_app}" = "yes"]) + +dnl Sample UniMRCP client application in C++. +AC_ARG_ENABLE(umc, + [AC_HELP_STRING([--disable-umc ],[exclude sample unimrcpclient C++ app from build])], + [enable_umc="$enableval"], + [enable_umc="yes"]) + +AM_CONDITIONAL([UMC],[test "${enable_client_lib}" = "yes" && test "${enable_umc}" = "yes"]) + +dnl Miscellaneous ASR client library and application. +AC_ARG_ENABLE(asr-client, + [AC_HELP_STRING([--disable-asr-client ],[exclude misc ASR client lib and app from build])], + [enable_asr_client="$enableval"], + [enable_asr_client="yes"]) + +AM_CONDITIONAL([ASR_CLIENT],[test "${enable_client_lib}" = "yes" && test "${enable_asr_client}" = "yes"]) + +AM_CONDITIONAL([COMMON_CLIENT_DATA],[test "${enable_client_app}" = "yes" || test "${enable_umc}" = "yes" ||test "${enable_asr_client}" = "yes"]) + +dnl UniMRCP server library. +AC_ARG_ENABLE(server-lib, + [AC_HELP_STRING([--disable-server-lib ],[exclude unimrcpserver lib from build])], + [enable_server_lib="$enableval"], + [enable_server_lib="yes"]) + +AM_CONDITIONAL([UNIMRCP_SERVER_LIB],[test "${enable_server_lib}" = "yes"]) + +dnl UniMRCP server application. +AC_ARG_ENABLE(server-app, + [AC_HELP_STRING([--disable-server-app ],[exclude unimrcpserver app from build])], + [enable_server_app="$enableval"], + [enable_server_app="yes"]) + +AM_CONDITIONAL([UNIMRCP_SERVER_APP],[test "${enable_server_lib}" = "yes" && test "${enable_server_app}" = "yes"]) + +dnl Demo synthesizer plugin. +UNI_PLUGIN_ENABLED(demosynth) + +AM_CONDITIONAL([DEMOSYNTH_PLUGIN],[test "${enable_demosynth_plugin}" = "yes"]) + +dnl Demo recognizer plugin. +UNI_PLUGIN_ENABLED(demorecog) + +AM_CONDITIONAL([DEMORECOG_PLUGIN],[test "${enable_demorecog_plugin}" = "yes"]) + +dnl Demo verifier plugin. +UNI_PLUGIN_ENABLED(demoverifier) + +AM_CONDITIONAL([DEMOVERIFIER_PLUGIN],[test "${enable_demoverifier_plugin}" = "yes"]) + +dnl Recorder plugin. +UNI_PLUGIN_ENABLED(recorder) + +AM_CONDITIONAL([RECORDER_PLUGIN],[test "${enable_recorder_plugin}" = "yes"]) + +dnl Enable test suites. AC_ARG_ENABLE(test-suites, [AC_HELP_STRING([--enable-test-suites ],[build test suites])], [enable_test_suites="$enableval"], @@ -102,136 +192,82 @@ AC_ARG_ENABLE(test-suites, AM_CONDITIONAL([TEST_SUITES],[test "${enable_test_suites}" != "no"]) - -### Plugins ### - -#Enable demo synthesizer plugin -AC_ARG_ENABLE(demosynth-plugin, - [AC_HELP_STRING([--disable-demosynth-plugin ],[exclude demo synthesizer plugin from build])], - [enable_demosynth_plugin="$enableval"], - [enable_demosynth_plugin="yes"]) - -AM_CONDITIONAL([DEMOSYNTH_PLUGIN],[test "${enable_demosynth_plugin}" = "yes"]) - - -#Enable demo recognizer plugin -AC_ARG_ENABLE(demorecog-plugin, - [AC_HELP_STRING([--disable-demorecog-plugin ],[exclude demo recognizer plugin from build])], - [enable_demorecog_plugin="$enableval"], - [enable_demorecog_plugin="yes"]) - -AM_CONDITIONAL([DEMORECOG_PLUGIN],[test "${enable_demorecog_plugin}" = "yes"]) - - -#Enable demo verifier plugin -AC_ARG_ENABLE(demoverifier-plugin, - [AC_HELP_STRING([--disable-demoverifier-plugin ],[exclude demo verifier plugin from build])], - [enable_demoverifier_plugin="$enableval"], - [enable_demoverifier_plugin="yes"]) - -AM_CONDITIONAL([DEMOVERIFIER_PLUGIN],[test "${enable_demoverifier_plugin}" = "yes"]) - - -#Enable recorder plugin -AC_ARG_ENABLE(recorder-plugin, - [AC_HELP_STRING([--disable-recorder-plugin ],[exclude recorder plugin from build])], - [enable_recorder_plugin="$enableval"], - [enable_recorder_plugin="yes"]) - -AM_CONDITIONAL([RECORDER_PLUGIN],[test "${enable_recorder_plugin}" = "yes"]) - - -#Enable PocketSphinx plugin -AC_ARG_ENABLE(pocketsphinx-plugin, - [AC_HELP_STRING([--enable-pocketsphinx-plugin ],[enable pocketsphinx plugin])], - [enable_pocketsphinx_plugin="$enableval"], - [enable_pocketsphinx_plugin="no"]) - -if test "${enable_pocketsphinx_plugin}" != "no"; then - UNIMRCP_CHECK_SPHINXBASE - UNIMRCP_CHECK_POCKETSPHINX -fi - -AM_CONDITIONAL([POCKETSPHINX_PLUGIN],[test "${enable_pocketsphinx_plugin}" = "yes" &&\ - test "${found_pocketsphinx}" = "yes" &&\ - test "${found_sphinxbase}" = "yes"]) - - -#Enable Flite plugin -AC_ARG_ENABLE(flite-plugin, - [AC_HELP_STRING([--enable-flite-plugin ],[enable flite plugin])], - [enable_flite_plugin="$enableval"], - [enable_flite_plugin="no"]) - -if test "${enable_flite_plugin}" != "no"; then - UNIMRCP_CHECK_FLITE -fi - -AM_CONDITIONAL([FLITE_PLUGIN],[test "${enable_flite_plugin}" = "yes" &&\ - test "${found_flite}" = "yes"]) - - AM_CONDITIONAL(ISMAC, [test `uname -s` = Darwin]) AC_CONFIG_FILES([ - Makefile - libs/Makefile - libs/apr-toolkit/Makefile - libs/mpf/Makefile - libs/mrcp/Makefile - libs/mrcp-signaling/Makefile - libs/mrcpv2-transport/Makefile - libs/mrcp-engine/Makefile - libs/mrcp-server/Makefile - libs/mrcp-client/Makefile - libs/uni-rtsp/Makefile - modules/Makefile - modules/mrcp-sofiasip/Makefile - modules/mrcp-unirtsp/Makefile - plugins/Makefile - plugins/mrcp-pocketsphinx/Makefile - plugins/mrcp-flite/Makefile - plugins/mrcp-recorder/Makefile - plugins/demo-synth/Makefile - plugins/demo-recog/Makefile - plugins/demo-verifier/Makefile - platforms/Makefile - platforms/libunimrcp-server/Makefile - platforms/libunimrcp-client/Makefile - platforms/unimrcp-server/Makefile - platforms/unimrcp-client/Makefile - platforms/libasr-client/Makefile - platforms/asr-client/Makefile - platforms/umc/Makefile - tests/Makefile - tests/apttest/Makefile - tests/mpftest/Makefile - tests/mrcptest/Makefile - tests/rtsptest/Makefile - tests/strtablegen/Makefile - build/Makefile - build/pkgconfig/Makefile - build/pkgconfig/unimrcpclient.pc - build/pkgconfig/unimrcpserver.pc - build/pkgconfig/unimrcpplugin.pc - build/svnrev/Makefile - conf/Makefile - data/Makefile - docs/doxygen.conf + Makefile + libs/Makefile + libs/apr-toolkit/Makefile + libs/mpf/Makefile + libs/mrcp/Makefile + libs/mrcp-signaling/Makefile + libs/mrcpv2-transport/Makefile + libs/mrcp-engine/Makefile + libs/mrcp-server/Makefile + libs/mrcp-client/Makefile + libs/uni-rtsp/Makefile + modules/Makefile + modules/mrcp-sofiasip/Makefile + modules/mrcp-unirtsp/Makefile + plugins/Makefile + plugins/mrcp-recorder/Makefile + plugins/demo-synth/Makefile + plugins/demo-recog/Makefile + plugins/demo-verifier/Makefile + platforms/Makefile + platforms/libunimrcp-server/Makefile + platforms/libunimrcp-client/Makefile + platforms/unimrcp-server/Makefile + platforms/unimrcp-client/Makefile + platforms/libasr-client/Makefile + platforms/asr-client/Makefile + platforms/umc/Makefile + tests/Makefile + tests/apttest/Makefile + tests/mpftest/Makefile + tests/mrcptest/Makefile + tests/rtsptest/Makefile + tests/strtablegen/Makefile + build/Makefile + build/pkgconfig/Makefile + build/pkgconfig/unimrcpclient.pc + build/pkgconfig/unimrcpserver.pc + build/pkgconfig/unimrcpplugin.pc + conf/Makefile + data/Makefile + docs/doxygen.conf ]) AC_OUTPUT -AC_MSG_NOTICE -AC_MSG_NOTICE([Report:]) -AC_MSG_NOTICE([ UniMRCP: $UNI_DOTTED_VERSION]) -AC_MSG_NOTICE([ APR: $apr_version]) -AC_MSG_NOTICE([ APR-Util: $apu_version]) -AC_MSG_NOTICE([ Sofia-SIP: $sofia_version]) -AC_MSG_NOTICE([Plugins:]) -AC_MSG_NOTICE([ Demo Synthesizer: $enable_demosynth_plugin]) -AC_MSG_NOTICE([ Demo Recognizer: $enable_demorecog_plugin]) -AC_MSG_NOTICE([ Demo Verifier: $enable_demoverifier_plugin]) -AC_MSG_NOTICE([ Recorder: $enable_recorder_plugin]) -AC_MSG_NOTICE([ PocketSphinx: $enable_pocketsphinx_plugin]) -AC_MSG_NOTICE([ Flite: $enable_flite_plugin]) +echo +echo '****************************** REPORT ******************************' +echo +echo UniMRCP version............... : $UNI_DOTTED_VERSION +echo +echo APR version................... : $apr_version +echo APR-util version.............. : $apu_version +echo Sofia-SIP version............. : $sofia_version +echo +echo Compiler...................... : $CC +echo Compiler flags................ : $CFLAGS +echo Preprocessor definitions...... : $CPPFLAGS +echo Linker flags.................. : $LDFLAGS +echo +echo UniMRCP client lib............ : $enable_client_lib +echo Sample UniMRCP client app..... : $enable_client_app +echo Sample UMC C++ client app..... : $enable_umc +echo Misc ASR client lib and app... : $enable_asr_client +echo +echo UniMRCP server lib............ : $enable_server_lib +echo UniMRCP server app............ : $enable_server_app +echo +echo Demo synthesizer plugin....... : $enable_demosynth_plugin +echo Demo recognizer plugin........ : $enable_demorecog_plugin +echo Demo verifier plugin.......... : $enable_demoverifier_plugin +echo Recorder plugin............... : $enable_recorder_plugin +echo +echo Installation layout........... : $layout_name +echo Installation directory........ : $prefix +echo +echo '********************************************************************' diff --git a/libs/unimrcp/configure.gnu b/libs/unimrcp/configure.gnu old mode 100644 new mode 100755 index ee8d194b03..c8aef238bc --- a/libs/unimrcp/configure.gnu +++ b/libs/unimrcp/configure.gnu @@ -1,4 +1,4 @@ #! /bin/sh -srcpath=$(dirname $0 2>/dev/null ) || srcpath="." -$srcpath/configure "$@" --with-apr=../apr --disable-shared --with-pic --with-apr-util=../apr-util --with-sofia-sip=../sofia-sip +srcpath=$(pwd) +$srcpath/configure "$@" --with-apr=$srcpath/../apr --disable-shared --with-pic --with-apr-util=$srcpath/../apr-util --with-sofia-sip=$srcpath/../sofia-sip diff --git a/libs/unimrcp/data/Makefile.am b/libs/unimrcp/data/Makefile.am index b8a3d4d2d9..60b540646b 100644 --- a/libs/unimrcp/data/Makefile.am +++ b/libs/unimrcp/data/Makefile.am @@ -1,11 +1,31 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in + +DATAFILES = + +if COMMON_CLIENT_DATA +DATAFILES += grammar.jsgf grammar.mixed grammar.srgs grammar.xml \ + speak.txt speak.xml \ + one-16kHz.pcm one-8kHz.pcm \ + johnsmith-16kHz.pcm johnsmith-8kHz.pcm +endif + +if DEMOSYNTH_PLUGIN +DATAFILES += demo-16kHz.pcm demo-8kHz.pcm +endif + +if DEMORECOG_PLUGIN +DATAFILES += result.xml +endif + +if DEMOVERIFIER_PLUGIN +DATAFILES += result-verification.xml +endif def-data: - test -d $(datadir) || $(mkinstalldirs) $(datadir) - for datafile in `find ./ -name \*.pcm -o -name \*.xml -o -name \*.jsgf -o -name \*.txt` ; do \ - filename=`echo $$datafile | sed -e 's|^.*/||'`; \ - $(INSTALL) -m 644 $$filename $(datadir); \ + test -d $(DESTDIR)$(datadir) || $(mkinstalldirs) $(DESTDIR)$(datadir) + for datafile in $(DATAFILES) ; do \ + $(INSTALL) -m 644 $(top_srcdir)/data/$$datafile $(DESTDIR)$(datadir); \ done - + install-data-local: - test -d $(datadir) || $(MAKE) def-data + test -d $(DESTDIR)$(datadir) || $(MAKE) def-data diff --git a/libs/unimrcp/data/grammar.jsgf b/libs/unimrcp/data/grammar.jsgf index df19bb9fd9..9257ecdca2 100644 --- a/libs/unimrcp/data/grammar.jsgf +++ b/libs/unimrcp/data/grammar.jsgf @@ -1,3 +1,3 @@ -#JSGF V1.0; -grammar digits; -public = (one | two | three); +#JSGF V1.0; +grammar digits; +public = (one | two | three); diff --git a/libs/unimrcp/data/grammar.mixed b/libs/unimrcp/data/grammar.mixed index 2f706e7632..dabe3a1c88 100644 --- a/libs/unimrcp/data/grammar.mixed +++ b/libs/unimrcp/data/grammar.mixed @@ -1,19 +1,19 @@ - ---break -Content-Type:text/uri-list -Content-Length: 22 - -builtin:grammar/digits - ---break -Content-Type:application/srgs+xml -Content-Length: 230 - - - - - one two three four five - - + +--break +Content-Type:text/uri-list +Content-Length: 22 + +builtin:grammar/digits + +--break +Content-Type:application/srgs+xml +Content-Length: 230 + + + + + one two three four five + + --break-- \ No newline at end of file diff --git a/libs/unimrcp/data/grammar.srgs b/libs/unimrcp/data/grammar.srgs new file mode 100644 index 0000000000..6457d725d3 --- /dev/null +++ b/libs/unimrcp/data/grammar.srgs @@ -0,0 +1,4 @@ +#ABNF 1.0; +language en-US; +mode voice; +public $digit = one | two | three; \ No newline at end of file diff --git a/libs/unimrcp/data/grammar.xml b/libs/unimrcp/data/grammar.xml index 3e84ebc38a..a6dbf88fa3 100644 --- a/libs/unimrcp/data/grammar.xml +++ b/libs/unimrcp/data/grammar.xml @@ -1,10 +1,10 @@ - - - - - one - two - three - - + + + + + one + two + three + + \ No newline at end of file diff --git a/libs/unimrcp/data/result-verification.xml b/libs/unimrcp/data/result-verification.xml index fa0c8ceef3..8ab8a32fb6 100644 --- a/libs/unimrcp/data/result-verification.xml +++ b/libs/unimrcp/data/result-verification.xml @@ -1,21 +1,21 @@ - - - - - - 500 - cellular-phone - male - accepted - 0.85 - - - 1500 - cellular-phone - male - accepted - 0.75 - - - + + + + + + 500 + cellular-phone + male + accepted + 0.85 + + + 1500 + cellular-phone + male + accepted + 0.75 + + + \ No newline at end of file diff --git a/libs/unimrcp/data/result.xml b/libs/unimrcp/data/result.xml index e75c6e4b5f..74a1171e3c 100644 --- a/libs/unimrcp/data/result.xml +++ b/libs/unimrcp/data/result.xml @@ -1,7 +1,7 @@ - - - - one - one - + + + + one + one + \ No newline at end of file diff --git a/libs/unimrcp/data/speak.xml b/libs/unimrcp/data/speak.xml index c64e8dfb31..2a49ff048c 100644 --- a/libs/unimrcp/data/speak.xml +++ b/libs/unimrcp/data/speak.xml @@ -1,6 +1,6 @@ - - -

- Welcome to Uni MRCP. -

+ + +

+ Welcome to Uni MRCP. +

\ No newline at end of file diff --git a/libs/unimrcp/docs/mainpage.docs b/libs/unimrcp/docs/mainpage.docs index 8961b43da3..7081702f57 100644 --- a/libs/unimrcp/docs/mainpage.docs +++ b/libs/unimrcp/docs/mainpage.docs @@ -1,92 +1,71 @@ /** -@mainpage UniMRCP +@mainpage UniMRCP API Reference
@section Introduction -UniMRCP is an open source cross-platform MRCP project, which provides everything required for MRCP client and server side deployment. -
-UniMRCP encapsulates SIP/MRCPv2, RTSP, SDP and RTP/RTCP stacks inside and provides MRCP version independent user level interface for the integration. +UniMRCP is an open source project compliant with the IETF RFC6787 (MRCPv2) and RFC4463 (MRCPv1) specifications. +The project encapsulates SIP, RTSP, SDP, MRCPv2, and RTP/RTCP stacks and provides integrators with a protocol version consistent interface. + +- Compliance: MRCPv1, MRCPv2 (client and server) +- Resources: Synthesizer (TTS), Recognizer (ASR), Verifier (SVI), Recorder +- License: Apache 2.0 +- OS: Cross-platform (Windows, Linux, ...) +- Language: C, C++

-@section Source Tree Structure +@section _ Source Tree Structure
-Libraries - -* apr-toolkit - set of utilities built on top of APR and APR-Util libraries (task abstraction, logging, etc) -
-* mpf - media processing framework -
-* mrcp - implementation of MRCP basics (message, parser, resources) -
-* mrcpv2-transport - implementation of MRCPv2 transport layer -
-* mrcp-signaling - abstract MRCP signaling (session management) interface -
-* mrcp-engine - abstract resource engine interface -
-* mrcp-client - implementation of MRCP client stack based on abstract signaling interface -
-* mrcp-server - implementation of MRCP server stack based on abstract signaling and engine interfaces -
-* uni-rtsp - implementation of minimal RTSP stack required for MRCPv1 +@subsection Libraries +- apr-toolkit - Set of utilities built on top of the APR and APR-util libraries (task abstraction, logging, etc). +- mpf - Media processing framework. +- mrcp - Implementation of MRCP basics (message, parser, resources). +- mrcpv2-transport - Implementation of the MRCPv2 transport layer. +- mrcp-signaling - Abstract MRCP signaling (session management) interface. +- mrcp-engine - Abstract resource engine interface. +- mrcp-client - Implementation of an MRCP client stack based on the abstract signaling interface. +- mrcp-server - Implementation of an MRCP server stack based on the abstract signaling and engine interfaces. +- uni-rtsp - Implementation of a minimal RTSP stack required for MRCPv1.
-Modules - -* mrcp-sofiasip - implementation of abstract signaling interface using SofiaSIP library -
-* mrcp-unirtsp - implementation of abstract signaling interface using UniRTSP library -
+@subsection Modules +- mrcp-sofiasip - Implementation of the abstract signaling interface using the SofiaSIP library. +- mrcp-unirtsp - Implementation of the abstract signaling interface using the UniRTSP library.
-Plugins +@subsection Plugins -* demo-synth - simulation of actual synthesizer engine -
-* demo-recog - simulation of actual recognizer engine -
-* mrcp-recorder - implementation of recorder resource -
-* mrcp-flite - implementation of synthesizer resource using open source Flite engine -
-* mrcp-pocketsphinx - implementation of recognizer resource using open source PocketSphinx engine +- demo-synth - Implementation of a TTS plugin which simulates synthesis. +- demo-recog - Implementation of an ASR plugin which simulates recognition. +- demo-verif - Implementation of an SVI plugin which simulates speaker verification. +- mrcp-recorder - Implementation of a recorder plugin.
-Platforms +@subsection Platforms -* libunimrcpclient - unimrcp client stack based on libraries and modules above -
-* libunimrcpserver - unimrcp server stack based on libraries, modules and plugins above -
-* unimrcpclient - sample C application based on unimrcp client stack -
-* umc - sample C++ application based on unimrcp client stack -
-* unimrcpserver - final unimrcp server application +- libunimrcpclient - The UniMRCP client stack built on top of the underlying mrcp-client library using the mrcp-sofiasip and mrcp-unirtsp modules. +- libunimrcpserver - The UniMRCP server stack based on top of the underlying mrcp-server library using the mrcp-sofiasip and mrcp-unirtsp modules. +- unimrcpclient - Sample C application based on the UniMRCP client stack. +- umc - Sample C++ application based on the UniMRCP client stack. +- unimrcpserver - The UniMRCP server application.
@section Dependencies - APR - Apache Portable Runtime -
- Sofia-SIP - SIP User Agent Library +- APR - Apache Portable Runtime Library +- Sofia-SIP - SIP User Agent Library
@section Project Links - Website -
- Downloads -
- Wiki -
- Issue Tracker -
- Discussion Group +- Website +- Downloads +- Documentation +- Issue Tracker +- Discussion Group
*/ diff --git a/libs/unimrcp/libs/apr-toolkit/Makefile.am b/libs/unimrcp/libs/apr-toolkit/Makefile.am index 1b78fdf6eb..aed07a7fb2 100644 --- a/libs/unimrcp/libs/apr-toolkit/Makefile.am +++ b/libs/unimrcp/libs/apr-toolkit/Makefile.am @@ -1,7 +1,7 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libaprtoolkit.la diff --git a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2008.vcproj b/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2008.vcproj deleted file mode 100644 index db29dc95da..0000000000 --- a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2008.vcproj +++ /dev/null @@ -1,433 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2012.vcxproj b/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2012.vcxproj deleted file mode 100644 index 646ab231ea..0000000000 --- a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2012.vcxproj +++ /dev/null @@ -1,167 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - aprtoolkit - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - aprtoolkit - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {f057da7f-79e5-4b00-845c-ef446ef055e3} - false - - - - - - diff --git a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2010.vcxproj b/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj similarity index 64% rename from libs/unimrcp/libs/apr-toolkit/aprtoolkit.2010.vcxproj rename to libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj index 5a8627dbff..1c4031a02e 100644 --- a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.2010.vcxproj +++ b/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj @@ -1,163 +1,139 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - aprtoolkit - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - aprtoolkit - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {f057da7f-79e5-4b00-845c-ef446ef055e3} - false - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} + aprtoolkit + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj.filters b/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj.filters new file mode 100644 index 0000000000..3a67d6084e --- /dev/null +++ b/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcxproj.filters @@ -0,0 +1,143 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4e9335ac-20e8-4284-ad77-20ad9190c94d} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt.h b/libs/unimrcp/libs/apr-toolkit/include/apt.h index 963b28b65a..a25a6e28f1 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt.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: apt.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_consumer_task.h b/libs/unimrcp/libs/apr-toolkit/include/apt_consumer_task.h index 9085f0c3ba..2f33426737 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_consumer_task.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_consumer_task.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: apt_consumer_task.h 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_consumer_task.h 2175 2014-09-12 04:56:09Z achaloyan@gmail.com $ */ #ifndef APT_CONSUMER_TASK_H @@ -25,6 +25,7 @@ */ #include "apt_task.h" +#include "apt_timer_queue.h" APT_BEGIN_EXTERN_C @@ -52,7 +53,7 @@ APT_DECLARE(apt_task_t*) apt_consumer_task_base_get(const apt_consumer_task_t *t * Get task vtable. * @param task the consumer task to get vtable for */ -APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(apt_consumer_task_t *task); +APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(const apt_consumer_task_t *task); /** * Get consumer task object. @@ -60,6 +61,19 @@ APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(apt_consumer_task_t */ APT_DECLARE(void*) apt_consumer_task_object_get(const apt_consumer_task_t *task); +/** + * Create timer. + * @param task the consumer task to create timer for + * @param proc the timer callback + * @param obj the object to pass to callback + * @param pool the pool to allocate memory from + */ +APT_DECLARE(apt_timer_t*) apt_consumer_task_timer_create( + apt_consumer_task_t *task, + apt_timer_proc_f proc, + void *obj, + apr_pool_t *pool); + APT_END_EXTERN_C #endif /* APT_CONSUMER_TASK_H */ diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_cyclic_queue.h b/libs/unimrcp/libs/apr-toolkit/include/apt_cyclic_queue.h index b0500855d6..bf803e2dde 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_cyclic_queue.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_cyclic_queue.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: apt_cyclic_queue.h 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_cyclic_queue.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_CYCLIC_QUEUE_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_dir_layout.h b/libs/unimrcp/libs/apr-toolkit/include/apt_dir_layout.h index 6adda9fab8..ba2fa16421 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_dir_layout.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_dir_layout.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: apt_dir_layout.h 1524 2010-02-15 20:44:16Z achaloyan $ + * $Id: apt_dir_layout.h 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $ */ #ifndef APT_DIR_LAYOUT_H @@ -21,48 +21,140 @@ /** * @file apt_dir_layout.h - * @brief Directory Layout - */ + * @brief Directories Layout + */ #include "apt.h" APT_BEGIN_EXTERN_C -/** Directory layout declaration */ +/* + * This define allows user applications to support both the old interface, + * where members of apt_dir_layout_t structure were accessable to the + * application, and the new opaque interface, where OPAQUE_DIR_LAYOUT + * is defined. + */ +#define OPAQUE_DIR_LAYOUT + +/** Directories layout declaration */ typedef struct apt_dir_layout_t apt_dir_layout_t; -/** Directory layout */ -struct apt_dir_layout_t { - /** Path to config dir */ - char *conf_dir_path; - /** Path to plugin dir */ - char *plugin_dir_path; - /** Path to log dir */ - char *log_dir_path; - /** Path to data dir */ - char *data_dir_path; -}; +/** Enumeration of directories the layout is composed of */ +typedef enum { + APT_LAYOUT_CONF_DIR, /**< configuration directory */ + APT_LAYOUT_PLUGIN_DIR, /**< plugin directory */ + APT_LAYOUT_LOG_DIR, /**< log directory */ + APT_LAYOUT_DATA_DIR, /**< data directory */ + APT_LAYOUT_VAR_DIR, /**< var directory */ + + APT_LAYOUT_DIR_COUNT, /**< number of directories in the default layout */ + + APT_LAYOUT_EXT_DIR = APT_LAYOUT_DIR_COUNT +} apt_dir_entry_id; /** - * Create (allocate) the structure of default directories layout. + * Create the default directories layout based on the specified root directory. + * @param root_dir_path the path to the root directory + * @param pool the memory pool to use */ APT_DECLARE(apt_dir_layout_t*) apt_default_dir_layout_create(const char *root_dir_path, apr_pool_t *pool); /** - * Create (allocate) the structure of custom directories layout. + * Create a custom directories layout based on the specified individual directories. + * @param conf_dir_path the path to the config dir + * @param plugin_dir_path the path to the plugin dir + * @param log_dir_path the path to the log dir + * @param var_dir_path the path to the var dir + * @param pool the memory pool to use */ APT_DECLARE(apt_dir_layout_t*) apt_custom_dir_layout_create( const char *conf_dir_path, const char *plugin_dir_path, const char *log_dir_path, const char *data_dir_path, + const char *var_dir_path, apr_pool_t *pool); -/** Construct file path relative to data dir using the file name specified. */ +/** + * Create a bare directories layout. + * @param pool the memory pool to use + */ +APT_DECLARE(apt_dir_layout_t*) apt_dir_layout_create(apr_pool_t *pool); + +/** + * Create am extended bare directories layout. + * @param count the number of directories in the layout + * @param pool the memory pool to use + */ +APT_DECLARE(apt_dir_layout_t*) apt_dir_layout_create_ext(apr_size_t count, apr_pool_t *pool); + +/** + * Load directories layout from the specified configuration file. + * @param dir_layout the directory layout + * @param config_file the path to the configuration file + * @param pool the memory pool to use + */ +APT_DECLARE(apt_bool_t) apt_dir_layout_load(apt_dir_layout_t *dir_layout, const char *config_file, apr_pool_t *pool); + +/** + * Load directories layout from the specified configuration file using the provided labels. + * @param dir_layout the directory layout + * @param config_file the path to the configuration file + * @param labels the array of directory labels (configuration entries) + * @param count the number of labels (normally equals the number of directories in the layout) + * @param pool the memory pool to use + */ +APT_DECLARE(apt_bool_t) apt_dir_layout_load_ext(apt_dir_layout_t *dir_layout, const char *config_file, const char **labels, apr_size_t count, apr_pool_t *pool); + +/** + * Set the path to the individual directory in the layout. + * @param dir_layout the directory layout + * @param dir_entry_id the directory id (apt_dir_entry_id) + * @param path the directory path + * @param pool the memory pool to use + */ +APT_DECLARE(apt_bool_t) apt_dir_layout_path_set(apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *path, apr_pool_t *pool); + +/** + * Get the path to the individual directory in the layout. + * @param dir_layout the directory layout + * @param dir_entry_id the directory id (apt_dir_entry_id) + */ +APT_DECLARE(const char*) apt_dir_layout_path_get(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id); + +/** + * Compose a file path relative to the specified directory in the layout. + * @param dir_layout the directory layout + * @param dir_entry_id the directory id (apt_dir_entry_id) + * @param file_name the file name to append to the directory path + * @param pool the memory pool to use + */ +APT_DECLARE(char*) apt_dir_layout_path_compose(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *file_name, apr_pool_t *pool); + + +/** + * Compose a file path relative to config dir. + * @param dir_layout the directory layout + * @param file_name the file name + * @param pool the memory pool to use + */ +APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool); + +/** + * Compose a file path relative to data dir. + * @param dir_layout the directory layout + * @param file_name the file name + * @param pool the memory pool to use + */ APT_DECLARE(char*) apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool); -/** Construct file path relative to conf dir using the file name specified. */ -APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool); +/** + * Compose a file path relative to var dir. + * @param dir_layout the directory layout + * @param file_name the file name + * @param pool the memory pool to use + */ +APT_DECLARE(char*) apt_vardir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool); APT_END_EXTERN_C diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_header_field.h b/libs/unimrcp/libs/apr-toolkit/include/apt_header_field.h index 72932059dd..b2e7053748 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_header_field.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_header_field.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: apt_header_field.h 1719 2010-05-31 21:09:51Z achaloyan $ + * $Id: apt_header_field.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_HEADER_FIELD_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_log.h b/libs/unimrcp/libs/apr-toolkit/include/apt_log.h index 4d7c1bc5ed..a9ec8d91c6 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_log.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_log.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: apt_log.h 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: apt_log.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_LOG_H @@ -32,14 +32,27 @@ APT_BEGIN_EXTERN_C /** Default max size of the log file (8Mb) */ #define MAX_LOG_FILE_SIZE (8 * 1024 * 1024) -/** Default max number of rotated log files */ -#define MAX_LOG_FILE_COUNT 10 +/** Default max number of log files used in rotation */ +#define MAX_LOG_FILE_COUNT 100 /** File:line mark */ -#define APT_LOG_MARK __FILE__,__LINE__ +#define APT_LOG_MARK __FILE__,__LINE__ +/* + * Definition of common formats used with apt_log(). + * + * Note that the generic %p format can not be used for pointers + * since apr_vformatter doesn't accept it. The format %pp introduced + * by apr_vformatter can not be used either since it breaks compatibility + * with generic printf style loggers. + */ +#if defined(WIN32) && APR_SIZEOF_VOIDP == 8 +/** Format to log pointer values on Win x64 */ +#define APT_PTR_FMT "0x%I64x" +#else /** Format to log pointer values */ -#define APT_PTR_FMT "0x%x" +#define APT_PTR_FMT "0x%lx" +#endif /** Format to log string identifiers */ #define APT_SID_FMT "<%s>" /** Format to log string identifiers and resources */ @@ -51,7 +64,6 @@ APT_BEGIN_EXTERN_C /** Format to log names, identifiers and resources */ #define APT_NAMESIDRES_FMT "%s "APT_SIDRES_FMT - /** Priority of log messages ordered from highest priority to lowest (rfc3164) */ typedef enum { APT_PRIO_EMERGENCY, /**< system is unusable */ @@ -96,8 +108,9 @@ typedef enum { typedef struct apt_logger_t apt_logger_t; /** Prototype of extended log handler function */ -typedef apt_bool_t (*apt_log_ext_handler_f)(const char *file, int line, const char *obj, - apt_log_priority_e priority, const char *format, va_list arg_ptr); +typedef apt_bool_t (*apt_log_ext_handler_f)(const char *file, int line, + const char *obj, apt_log_priority_e priority, + const char *format, va_list arg_ptr); /** * Create the singleton instance of the logger. @@ -202,7 +215,7 @@ APT_DECLARE(apt_bool_t) apt_log_masking_set(apt_log_masking_e masking); /** * Get the current masking mode of private data. */ -APT_DECLARE(apt_log_masking_e) apt_log_masking_get(); +APT_DECLARE(apt_log_masking_e) apt_log_masking_get(void); /** * Translate the masking mode string to enum. @@ -237,7 +250,7 @@ APT_DECLARE(apt_bool_t) apt_log_ext_handler_set(apt_log_ext_handler_f handler); APT_DECLARE(apt_bool_t) apt_log(const char *file, int line, apt_log_priority_e priority, const char *format, ...); /** - * Do logging. + * Do logging (this version uses an object externally associated with the logger). * @param file the file name log entry is generated from * @param line the line number log entry is generated from * @param priority the priority of the entire log entry @@ -246,6 +259,16 @@ APT_DECLARE(apt_bool_t) apt_log(const char *file, int line, apt_log_priority_e p */ APT_DECLARE(apt_bool_t) apt_obj_log(const char *file, int line, apt_log_priority_e priority, void *obj, const char *format, ...); +/** + * Do logging (this version accepts va_list argument). + * @param file the file name log entry is generated from + * @param line the line number log entry is generated from + * @param priority the priority of the entire log entry + * @param format the format of the entire log entry + * @param arg_ptr the arguments + */ +APT_DECLARE(apt_bool_t) apt_va_log(const char *file, int line, apt_log_priority_e priority, const char *format, va_list arg_ptr); + APT_END_EXTERN_C #endif /* APT_LOG_H */ diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_multipart_content.h b/libs/unimrcp/libs/apr-toolkit/include/apt_multipart_content.h index c3f2dd8de2..dd4c646d83 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_multipart_content.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_multipart_content.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: apt_multipart_content.h 1722 2010-06-01 08:40:35Z achaloyan $ + * $Id: apt_multipart_content.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_MULTIPART_CONTENT_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_net.h b/libs/unimrcp/libs/apr-toolkit/include/apt_net.h index d413c7f871..6527c8fc7d 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_net.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_net.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: apt_net.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_net.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_NET_H @@ -30,11 +30,18 @@ APT_BEGIN_EXTERN_C /** * Get the IP address (in numeric address string format) by hostname. - * @param addr the IP address + * @param addr the IP address to return * @param pool the pool to allocate memory from */ apt_bool_t apt_ip_get(char **addr, apr_pool_t *pool); +/** + * Get the IP address (in numeric address string format) by network interface name. + * @param iface_name the network interface name (eth0, Local Area Connection, etc) + * @param addr the IP address to return + * @param pool the pool to allocate memory from + */ +apt_bool_t apt_ip_get_by_iface(const char *iface_name, char **addr, apr_pool_t *pool); /** * Get current NTP time diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h b/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h index ca29a07ad8..d6b87c87d9 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.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: apt_nlsml_doc.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_nlsml_doc.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_NLSML_DOC_H @@ -21,29 +21,189 @@ /** * @file apt_nlsml_doc.h - * @brief Basic NLSML Routine - */ + * @brief NLSML Result Handling + * @remark This is an MRCP version independent and vendor consistent implementation + * of the NSLML parser. The interface reflects the NLSML schema defined in + * http://tools.ietf.org/html/rfc6787#section-16.1. + */ -#include "apr_xml.h" -#include "apt_string.h" +#include +#include "apt.h" APT_BEGIN_EXTERN_C -/** Load NLSML document */ -APT_DECLARE(apr_xml_doc*) nlsml_doc_load(const apt_str_t *data, apr_pool_t *pool); +/* Forward declarations */ +typedef struct nlsml_result_t nlsml_result_t; +typedef struct nlsml_interpretation_t nlsml_interpretation_t; +typedef struct nlsml_enrollment_result_t nlsml_enrollment_result_t; +typedef struct nlsml_verification_result_t nlsml_verification_result_t; +typedef struct nlsml_instance_t nlsml_instance_t; +typedef struct nlsml_input_t nlsml_input_t; -/** Get the first interpretation element */ -APT_DECLARE(apr_xml_elem*) nlsml_first_interpret_get(const apr_xml_doc *doc); +/** + * Parse NLSML result + * @param data the data to parse + * @param length the length of the data + * @param pool the memory pool to use + * @return the parsed NLSML result. + */ +APT_DECLARE(nlsml_result_t*) nlsml_result_parse(const char *data, apr_size_t length, apr_pool_t *pool); -/** Get the next interpretation element */ -APT_DECLARE(apr_xml_elem*) nlsml_next_interpret_get(const apr_xml_elem *interpret); +/** + * Trace parsed NLSML result (for debug purposes only) + * @param result the parsed result to output + * @param pool the memory pool to use + */ +APT_DECLARE(void) nlsml_result_trace(const nlsml_result_t *result, apr_pool_t *pool); -/** Get instance and input elements of interpretation element */ -APT_DECLARE(apt_bool_t) nlsml_interpret_results_get(const apr_xml_elem *interpret, apr_xml_elem **instance, apr_xml_elem **input); +/* + * Accessors of the NLSML element. + * Each element may contain one or more , , + * elements, and an optional attribute. + */ -/** Get specified atrribute of input element */ -APT_DECLARE(const char *) nlsml_input_attrib_get(const apr_xml_elem *input, const char *attrib, apt_bool_t recursive); +/** + * Get first interpretation + * @param result the parsed NLSML result which holds the list of interpretation elements + */ +APT_DECLARE(nlsml_interpretation_t*) nlsml_first_interpretation_get(const nlsml_result_t *result); +/** + * Get next interpretation + * @param result the parsed NLSML result which holds the list of interpretation elements + * @param interpretation the current interpretation element + */ +APT_DECLARE(nlsml_interpretation_t*) nlsml_next_interpretation_get(const nlsml_result_t *result, const nlsml_interpretation_t *interpretation); + +/** + * Get first enrollment result + * @param result the parsed NLSML result which holds the list of enrollment-result elements + */ +APT_DECLARE(nlsml_enrollment_result_t*) nlsml_first_enrollment_result_get(const nlsml_result_t *result); + +/** + * Get next enrollment result + * @param result the parsed NLSML result which holds the list of enrollment-result elements + * @param enrollment_result the current enrollment-result element + */ +APT_DECLARE(nlsml_enrollment_result_t*) nlsml_next_enrollment_result_get(const nlsml_result_t *result, const nlsml_enrollment_result_t *enrollment_result); + +/** + * Get first verification result + * @param result the parsed NLSML result which holds the list of verification-result elements + */ +APT_DECLARE(nlsml_verification_result_t*) nlsml_first_verification_result_get(const nlsml_result_t *result); + +/** + * Get next verification result + * @param result the parsed NLSML result which holds the list of verification-result elements + * @param verification_result the current verification-result element + */ +APT_DECLARE(nlsml_verification_result_t*) nlsml_next_verification_result_get(const nlsml_result_t *result, const nlsml_verification_result_t *verification_result); + +/** + * Get the grammar attribute of the NLSML result + * @param result the parsed result + */ +APT_DECLARE(const char*) nlsml_result_grammar_get(const nlsml_result_t *result); + +/* + * Accessors of the element. + */ + +/** + * Get first instance + * @param interpretation the parsed interpretation element which holds the list of instance elements + */ +APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_first_instance_get(const nlsml_interpretation_t *interpretation); + +/** + * Get next instance + * @param interpretation the parsed interpretation element which holds the list of instance elements + * @param instance the current instance element + */ +APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_next_instance_get(const nlsml_interpretation_t *interpretation, const nlsml_instance_t *instance); + +/** + * Get input + * @param interpretation the parsed interpretation element which may have 0 or 1 input elements + */ +APT_DECLARE(nlsml_input_t*) nlsml_interpretation_input_get(const nlsml_interpretation_t *interpretation); + +/** + * Get interpretation confidence + * @param interpretation the parsed interpretation element + * @remark the confidence is stored and returned as a float value for both MRCPv2 and MRCPv1 + */ +APT_DECLARE(float) nlsml_interpretation_confidence_get(const nlsml_interpretation_t *interpretation); + +/** + * Get interpretation grammar + * @param interpretation the parsed interpretation element + */ +APT_DECLARE(const char*) nlsml_interpretation_grammar_get(const nlsml_interpretation_t *interpretation); + +/* + * Accessors of the and elements. + */ + +/** + * Get an XML representation of the instance element + * @param instance the parsed instance element + */ +APT_DECLARE(const apr_xml_elem*) nlsml_instance_elem_get(const nlsml_instance_t *instance); + +/** + * Suppress SWI elements (normalize instance) + * @param instance the parsed instance to suppress SWI sub-elements from + */ +APT_DECLARE(apt_bool_t) nlsml_instance_swi_suppress(nlsml_instance_t *instance); + +/** + * Generate a plain text content of the instance element + * @param instance the parsed instance to generate content of + * @param pool the memory pool to use + */ +APT_DECLARE(const char*) nlsml_instance_content_generate(const nlsml_instance_t *instance, apr_pool_t *pool); + +/** + * Get an XML representation of the input element + * @param input the parsed input element + */ +APT_DECLARE(const apr_xml_elem*) nlsml_input_elem_get(const nlsml_input_t *input); + +/** + * Generate a plain text content of the input element + * @param input the parsed input to generate content of + * @param pool the memory pool to use + */ +APT_DECLARE(const char*) nlsml_input_content_generate(const nlsml_input_t *input, apr_pool_t *pool); + +/** + * Get input mode + * @param input the parsed input element + * @remark the input mode is either "speech" or "dtmf" + */ +APT_DECLARE(const char*) nlsml_input_mode_get(const nlsml_input_t *input); + +/** + * Get input confidence + * @param input the parsed input element + * @remark the confidence is stored and returned as a float value for both MRCPv2 and MRCPv1 + */ +APT_DECLARE(float) nlsml_input_confidence_get(const nlsml_input_t *input); + +/** + * Get start of input timestamp + * @param input the parsed input element + */ +APT_DECLARE(const char*) nlsml_input_timestamp_start_get(const nlsml_input_t *input); + +/** + * Get end of input timestamp + * @param input the parsed input element + */ +APT_DECLARE(const char*) nlsml_input_timestamp_end_get(const nlsml_input_t *input); APT_END_EXTERN_C diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_obj_list.h b/libs/unimrcp/libs/apr-toolkit/include/apt_obj_list.h index 3d17a81595..56a88d0d4b 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_obj_list.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_obj_list.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: apt_obj_list.h 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_obj_list.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_OBJ_LIST_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_pair.h b/libs/unimrcp/libs/apr-toolkit/include/apt_pair.h index 4f3d8c55d6..737cff2157 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_pair.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_pair.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: apt_pair.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_pair.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_PAIR_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_poller_task.h b/libs/unimrcp/libs/apr-toolkit/include/apt_poller_task.h index e1a3c6a655..3bb6052744 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_poller_task.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_poller_task.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: apt_poller_task.h 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_poller_task.h 2176 2014-09-12 05:00:23Z achaloyan@gmail.com $ */ #ifndef APT_POLLER_TASK_H @@ -89,7 +89,7 @@ APT_DECLARE(apt_task_t*) apt_poller_task_base_get(const apt_poller_task_t *task) * Get task vtable. * @param task the poller task to get vtable from */ -APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(apt_poller_task_t *task); +APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(const apt_poller_task_t *task); /** * Get external object. @@ -98,10 +98,18 @@ APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(apt_poller_task_t *ta APT_DECLARE(void*) apt_poller_task_object_get(const apt_poller_task_t *task); /** - * Get pollset. - * @param task the poller task to get pollset from + * Add descriptor to pollset. + * @param task the task which holds the pollset + * @param descriptor the descriptor to add */ -APT_DECLARE(apt_pollset_t*) apt_poller_task_pollset_get(const apt_poller_task_t *task); +APT_DECLARE(apt_bool_t) apt_poller_task_descriptor_add(const apt_poller_task_t *task, const apr_pollfd_t *descriptor); + +/** + * Remove descriptor from pollset. + * @param task the task which holds the pollset + * @param descriptor the descriptor to remove + */ +APT_DECLARE(apt_bool_t) apt_poller_task_descriptor_remove(const apt_poller_task_t *task, const apr_pollfd_t *descriptor); /** * Create timer. diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_pollset.h b/libs/unimrcp/libs/apr-toolkit/include/apt_pollset.h index 3f7d56527b..0d6a0ab356 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_pollset.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_pollset.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: apt_pollset.h 1565 2010-03-06 07:13:04Z achaloyan $ + * $Id: apt_pollset.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_POLLSET_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_pool.h b/libs/unimrcp/libs/apr-toolkit/include/apt_pool.h index 7f1aabaf2b..56f10d4429 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_pool.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_pool.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: apt_pool.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_pool.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_POOL_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_string.h b/libs/unimrcp/libs/apr-toolkit/include/apt_string.h index 23be9655d4..4c919cedb6 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_string.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_string.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: apt_string.h 1531 2010-02-20 14:19:53Z achaloyan $ + * $Id: apt_string.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_STRING_H @@ -140,6 +140,17 @@ static APR_INLINE apt_bool_t apt_string_compare(const apt_str_t *str1, const apt return (strncasecmp(str1->buf,str2->buf,str1->length) == 0) ? TRUE : FALSE; } +/** + * Represent string as iovec. + * @param str the string to represent + * @param vec the iovec to set + */ +static APR_INLINE void apt_string_to_iovec(const apt_str_t *str, struct iovec *vec) +{ + vec->iov_base = str->buf; + vec->iov_len = str->length; +} + APT_END_EXTERN_C #endif /* APT_STRING_H */ diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_string_table.h b/libs/unimrcp/libs/apr-toolkit/include/apt_string_table.h index 3ba927f44e..53ecc6e5aa 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_string_table.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_string_table.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: apt_string_table.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_string_table.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_STRING_TABLE_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_task.h b/libs/unimrcp/libs/apr-toolkit/include/apt_task.h index 031eff6af8..127529c95e 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_task.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_task.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: apt_task.h 1696 2010-05-20 15:44:16Z achaloyan $ + * $Id: apt_task.h 2180 2014-09-13 21:17:24Z achaloyan@gmail.com $ */ #ifndef APT_TASK_H @@ -69,6 +69,18 @@ APT_DECLARE(apt_bool_t) apt_task_add(apt_task_t *task, apt_task_t *child_task); */ APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task); +/** + * Take task offline. + * @param task the task to take offline + */ +APT_DECLARE(apt_bool_t) apt_task_offline(apt_task_t *task); + +/** + * Bring task online. + * @param task the task to bring online + */ +APT_DECLARE(apt_bool_t) apt_task_online(apt_task_t *task); + /** * Terminate task. * @param task the task to terminate @@ -77,18 +89,6 @@ APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task); */ APT_DECLARE(apt_bool_t) apt_task_terminate(apt_task_t *task, apt_bool_t wait_till_complete); -/** - * Start child tasks. - * @param task the parent task - */ -APT_DECLARE(apt_bool_t) apt_task_child_start(apt_task_t *task); - -/** - * Terminate child tasks. - * @param task the parent task - */ -APT_DECLARE(apt_bool_t) apt_task_child_terminate(apt_task_t *task); - /** * Wait for task till complete. * @param task the task to wait for @@ -122,6 +122,19 @@ APT_DECLARE(apt_bool_t) apt_task_msg_parent_signal(apt_task_t *task, apt_task_ms */ APT_DECLARE(apt_bool_t) apt_task_msg_process(apt_task_t *task, apt_task_msg_t *msg); +/** + * Process task start request. + * @param task the task being started + */ +APT_DECLARE(apt_bool_t) apt_task_start_request_process(apt_task_t *task); + +/** + * Process task termination request. + * @param task the task being terminated + */ +APT_DECLARE(apt_bool_t) apt_task_terminate_request_process(apt_task_t *task); + + /** * Get parent (master) task. * @param task the task to get parent from @@ -220,23 +233,28 @@ struct apt_task_vtable_t { /** Virtual run method*/ apt_task_method_f run; - /** Virtual signal method */ + /** Virtual signal_msg method */ apt_bool_t (*signal_msg)(apt_task_t *task, apt_task_msg_t *msg); - /** Virtual process method */ + /** Virtual process_msg method */ apt_bool_t (*process_msg)(apt_task_t *task, apt_task_msg_t *msg); + /** Virtual process_start method */ + apt_bool_t (*process_start)(apt_task_t *task); + /** Virtual process_terminate method */ + apt_bool_t (*process_terminate)(apt_task_t *task); + /** Virtual pre-run event handler */ apt_task_event_f on_pre_run; /** Virtual post-run event handler */ apt_task_event_f on_post_run; - /** Virtual start-request event handler */ - apt_task_event_f on_start_request; /** Virtual start-complete event handler */ apt_task_event_f on_start_complete; - /** Virtual terminate-request event handler */ - apt_task_event_f on_terminate_request; /** Virtual terminate-complete event handler */ apt_task_event_f on_terminate_complete; + /** Virtual take-offline-complete event handler */ + apt_task_event_f on_offline_complete; + /** Virtual bring-online-complete event handler */ + apt_task_event_f on_online_complete; }; APT_END_EXTERN_C diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_task_msg.h b/libs/unimrcp/libs/apr-toolkit/include/apt_task_msg.h index 8680bf4491..afb01d2cd6 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_task_msg.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_task_msg.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: apt_task_msg.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_task_msg.h 2180 2014-09-13 21:17:24Z achaloyan@gmail.com $ */ #ifndef APT_TASK_MSG_H @@ -30,16 +30,20 @@ APT_BEGIN_EXTERN_C /** Enumeration of task message types */ typedef enum { - TASK_MSG_CORE, /**< core task message type */ - TASK_MSG_USER /**< user defined task messages start from here */ + TASK_MSG_CORE, /**< core task message type */ + TASK_MSG_USER /**< user defined task messages start from here */ } apt_task_msg_type_e; /** Enumeration of core task messages */ typedef enum { - CORE_TASK_MSG_NONE, /**< indefinite message */ - CORE_TASK_MSG_START_COMPLETE, /**< start-complete message */ - CORE_TASK_MSG_TERMINATE_REQUEST, /**< terminate-request message */ - CORE_TASK_MSG_TERMINATE_COMPLETE /**< terminate-complete message */ + CORE_TASK_MSG_NONE, /**< indefinite message */ + CORE_TASK_MSG_START_COMPLETE, /**< start-complete message */ + CORE_TASK_MSG_TERMINATE_REQUEST, /**< terminate-request message */ + CORE_TASK_MSG_TERMINATE_COMPLETE, /**< terminate-complete message */ + CORE_TASK_MSG_TAKEOFFLINE_REQUEST, /**< take-offline-request message */ + CORE_TASK_MSG_TAKEOFFLINE_COMPLETE, /**< take-offline-complete message */ + CORE_TASK_MSG_BRINGONLINE_REQUEST, /**< bring-online-request message */ + CORE_TASK_MSG_BRINGONLINE_COMPLETE, /**< bring-online-complete message */ } apt_core_task_msg_type_e; /** Opaque task message declaration */ @@ -52,7 +56,7 @@ struct apt_task_msg_t { /** Message pool the task message is allocated from */ apt_task_msg_pool_t *msg_pool; /** Task msg type */ - apt_task_msg_type_e type; + int type; /** Task msg sub type */ int sub_type; /** Context specific data */ diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_test_suite.h b/libs/unimrcp/libs/apr-toolkit/include/apt_test_suite.h index ce19f477c7..13e9003302 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_test_suite.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_test_suite.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: apt_test_suite.h 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_test_suite.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_TEST_SUITE_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_text_message.h b/libs/unimrcp/libs/apr-toolkit/include/apt_text_message.h index 40edf0af50..48e2f7c4c0 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_text_message.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_text_message.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: apt_text_message.h 1722 2010-06-01 08:40:35Z achaloyan $ + * $Id: apt_text_message.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_TEXT_MESSAGE_H diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_text_stream.h b/libs/unimrcp/libs/apr-toolkit/include/apt_text_stream.h index 3df2565145..7510afd9bc 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_text_stream.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_text_stream.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: apt_text_stream.h 1672 2010-04-28 20:37:22Z achaloyan $ + * $Id: apt_text_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_TEXT_STREAM_H @@ -96,18 +96,12 @@ APT_DECLARE(apt_bool_t) apt_pair_array_parse(apt_pair_arr_t *arr, const apt_str_ /** Generate array of name-value pairs */ APT_DECLARE(apt_bool_t) apt_pair_array_generate(const apt_pair_arr_t *arr, apt_str_t *str, apr_pool_t *pool); -/** Insert array of name-value pairs */ -APT_DECLARE(apt_bool_t) apt_text_pair_array_insert(apt_text_stream_t *stream, const apt_pair_arr_t *arr); - /** Parse boolean-value */ APT_DECLARE(apt_bool_t) apt_boolean_value_parse(const apt_str_t *str, apt_bool_t *value); /** Generate apr_size_t value from pool (buffer is allocated from pool) */ APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_str_t *str, apr_pool_t *pool); -/** Insert boolean-value */ -APT_DECLARE(apt_bool_t) apt_text_boolean_value_insert(apt_text_stream_t *stream, apt_bool_t value); - /** Parse apr_size_t value */ APT_DECLARE(apr_size_t) apt_size_value_parse(const apt_str_t *str); /** Generate apr_size_t value from pool (buffer is allocated from pool) */ diff --git a/libs/unimrcp/libs/apr-toolkit/include/apt_timer_queue.h b/libs/unimrcp/libs/apr-toolkit/include/apt_timer_queue.h index 0536e94a8d..ed04dd6514 100644 --- a/libs/unimrcp/libs/apr-toolkit/include/apt_timer_queue.h +++ b/libs/unimrcp/libs/apr-toolkit/include/apt_timer_queue.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: apt_timer_queue.h 1642 2010-04-08 13:37:57Z achaloyan $ + * $Id: apt_timer_queue.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef APT_TIMER_QUEUE_H diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_consumer_task.c b/libs/unimrcp/libs/apr-toolkit/src/apt_consumer_task.c index 28c691a274..67a9ea70dd 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_consumer_task.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_consumer_task.c @@ -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: apt_consumer_task.c 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_consumer_task.c 2224 2014-11-12 00:41:45Z achaloyan@gmail.com $ */ #include @@ -22,9 +22,12 @@ #include "apt_log.h" struct apt_consumer_task_t { - void *obj; - apt_task_t *base; - apr_queue_t *msg_queue; + void *obj; + apt_task_t *base; + apr_queue_t *msg_queue; +#if APR_HAS_QUEUE_TIMEOUT + apt_timer_queue_t *timer_queue; +#endif }; static apt_bool_t apt_consumer_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg); @@ -53,6 +56,11 @@ APT_DECLARE(apt_consumer_task_t*) apt_consumer_task_create( vtable->run = apt_consumer_task_run; vtable->signal_msg = apt_consumer_task_msg_signal; } + +#if APR_HAS_QUEUE_TIMEOUT + consumer_task->timer_queue = apt_timer_queue_create(pool); +#endif + return consumer_task; } @@ -61,7 +69,7 @@ APT_DECLARE(apt_task_t*) apt_consumer_task_base_get(const apt_consumer_task_t *t return task->base; } -APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(apt_consumer_task_t *task) +APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(const apt_consumer_task_t *task) { return apt_task_vtable_get(task->base); } @@ -71,6 +79,19 @@ APT_DECLARE(void*) apt_consumer_task_object_get(const apt_consumer_task_t *task) return task->obj; } +APT_DECLARE(apt_timer_t*) apt_consumer_task_timer_create( + apt_consumer_task_t *task, + apt_timer_proc_f proc, + void *obj, + apr_pool_t *pool) +{ +#if APR_HAS_QUEUE_TIMEOUT + return apt_timer_create(task->timer_queue,proc,obj,pool); +#else + return NULL; +#endif +} + static apt_bool_t apt_consumer_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg) { apt_consumer_task_t *consumer_task = apt_task_object_get(task); @@ -83,10 +104,18 @@ static apt_bool_t apt_consumer_task_run(apt_task_t *task) void *msg; apt_bool_t *running; apt_consumer_task_t *consumer_task; +#if APR_HAS_QUEUE_TIMEOUT + apr_interval_time_t timeout; + apr_uint32_t queue_timeout; + apr_time_t time_now, time_last = 0; +#endif + const char *task_name; + consumer_task = apt_task_object_get(task); if(!consumer_task) { return FALSE; } + task_name = apt_task_name_get(consumer_task->base), running = apt_task_running_flag_get(task); if(!running) { @@ -94,14 +123,42 @@ static apt_bool_t apt_consumer_task_run(apt_task_t *task) } while(*running) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s]",apt_task_name_get(task)); +#if APR_HAS_QUEUE_TIMEOUT + if(apt_timer_queue_timeout_get(consumer_task->timer_queue,&queue_timeout) == TRUE) { + timeout = (apr_interval_time_t)queue_timeout * 1000; + time_last = apr_time_now(); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s] timeout [%u]", + task_name, queue_timeout); + rv = apr_queue_timedpop(consumer_task->msg_queue,timeout,&msg); + } + else + { + timeout = -1; + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s]",task_name); + rv = apr_queue_pop(consumer_task->msg_queue,&msg); + } +#else + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s]",task_name); rv = apr_queue_pop(consumer_task->msg_queue,&msg); +#endif if(rv == APR_SUCCESS) { if(msg) { apt_task_msg_t *task_msg = msg; apt_task_msg_process(consumer_task->base,task_msg); } } + else if(rv != APR_TIMEUP) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Pop Message [%s] status: %d",task_name,rv); + } + +#if APR_HAS_QUEUE_TIMEOUT + if(timeout != -1) { + time_now = apr_time_now(); + if(time_now > time_last) { + apt_timer_queue_advance(consumer_task->timer_queue,(apr_uint32_t)((time_now - time_last)/1000)); + } + } +#endif } return TRUE; } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_cyclic_queue.c b/libs/unimrcp/libs/apr-toolkit/src/apt_cyclic_queue.c index 2ac36c4dbb..896a9f66fb 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_cyclic_queue.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_cyclic_queue.c @@ -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: apt_cyclic_queue.c 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_cyclic_queue.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_dir_layout.c b/libs/unimrcp/libs/apr-toolkit/src/apt_dir_layout.c index 2e651863d8..4fe3f4a120 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_dir_layout.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_dir_layout.c @@ -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,30 +13,93 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: apt_dir_layout.c 1524 2010-02-15 20:44:16Z achaloyan $ + * $Id: apt_dir_layout.c 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $ */ #include +#include #include "apt_dir_layout.h" -static apt_dir_layout_t* apt_dir_layout_alloc(apr_pool_t *pool) +/** Directories layout */ +struct apt_dir_layout_t { + /** Array of the directory paths the layout is composed of */ + const char **paths; + /** Number of directories in the layout */ + apr_size_t count; +}; + +/** Default labels matching the entries in configuration */ +static const char *default_labels[APT_LAYOUT_DIR_COUNT] = { + "confdir", /* APT_LAYOUT_CONF_DIR */ + "plugindir", /* APT_LAYOUT_PLUGIN_DIR */ + "logdir", /* APT_LAYOUT_LOG_DIR */ + "datadir", /* APT_LAYOUT_DATA_DIR */ + "vardir", /* APT_LAYOUT_VAR_DIR */ +}; + +static const char* apt_default_root_dir_path_get(apr_pool_t *pool) +{ + char *root_dir_path; + char *cur_dir_path; + /* Get the current directory */ + if(apr_filepath_get(&cur_dir_path,APR_FILEPATH_NATIVE,pool) != APR_SUCCESS) + return NULL; + + /* Root directory is supposed to be one level up by default */ + if(apr_filepath_merge(&root_dir_path,cur_dir_path,"../",APR_FILEPATH_NATIVE,pool) != APR_SUCCESS) + return FALSE; + + return root_dir_path; +} + +static apt_bool_t apt_dir_layout_path_set_internal(apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *path) +{ + if(dir_entry_id >= dir_layout->count) + return FALSE; + + dir_layout->paths[dir_entry_id] = path; + return TRUE; +} + +APT_DECLARE(apt_dir_layout_t*) apt_dir_layout_create(apr_pool_t *pool) +{ + return apt_dir_layout_create_ext(APT_LAYOUT_DIR_COUNT,pool); +} + +APT_DECLARE(apt_dir_layout_t*) apt_dir_layout_create_ext(apr_size_t count, apr_pool_t *pool) { apt_dir_layout_t *dir_layout = (apt_dir_layout_t*) apr_palloc(pool,sizeof(apt_dir_layout_t)); - dir_layout->conf_dir_path = NULL; - dir_layout->plugin_dir_path = NULL; - dir_layout->log_dir_path = NULL; - dir_layout->data_dir_path = NULL; + dir_layout->count = count; + dir_layout->paths = apr_pcalloc(pool,count*sizeof(char*)); return dir_layout; } APT_DECLARE(apt_dir_layout_t*) apt_default_dir_layout_create(const char *root_dir_path, apr_pool_t *pool) { - apt_dir_layout_t *dir_layout = apt_dir_layout_alloc(pool); + apt_dir_layout_t *dir_layout = apt_dir_layout_create_ext(APT_LAYOUT_DIR_COUNT,pool); + + if(!root_dir_path) { + /* If root dir path is not specified, get the default one */ + root_dir_path = apt_default_root_dir_path_get(pool); + } + if(root_dir_path) { - apr_filepath_merge(&dir_layout->conf_dir_path,root_dir_path,"conf",0,pool); - apr_filepath_merge(&dir_layout->plugin_dir_path,root_dir_path,"plugin",0,pool); - apr_filepath_merge(&dir_layout->log_dir_path,root_dir_path,"log",0,pool); - apr_filepath_merge(&dir_layout->data_dir_path,root_dir_path,"data",0,pool); + char *path; + + apr_filepath_merge(&path,root_dir_path,"conf",APR_FILEPATH_NATIVE,pool); + apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_CONF_DIR,path); + + apr_filepath_merge(&path,root_dir_path,"plugin",APR_FILEPATH_NATIVE,pool); + apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_PLUGIN_DIR,path); + + apr_filepath_merge(&path,root_dir_path,"log",APR_FILEPATH_NATIVE,pool); + apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_LOG_DIR,path); + + apr_filepath_merge(&path,root_dir_path,"data",APR_FILEPATH_NATIVE,pool); + apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_DATA_DIR,path); + + apr_filepath_merge(&path,root_dir_path,"var",APR_FILEPATH_NATIVE,pool); + apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_VAR_DIR,path); } return dir_layout; } @@ -46,42 +109,209 @@ APT_DECLARE(apt_dir_layout_t*) apt_custom_dir_layout_create( const char *plugin_dir_path, const char *log_dir_path, const char *data_dir_path, + const char *var_dir_path, apr_pool_t *pool) { - apt_dir_layout_t *dir_layout = apt_dir_layout_alloc(pool); - if(conf_dir_path) { - dir_layout->conf_dir_path = apr_pstrdup(pool,conf_dir_path); - } - if(plugin_dir_path) { - dir_layout->plugin_dir_path = apr_pstrdup(pool,plugin_dir_path); - } - if(log_dir_path) { - dir_layout->log_dir_path = apr_pstrdup(pool,log_dir_path); - } - if(data_dir_path) { - dir_layout->data_dir_path = apr_pstrdup(pool,data_dir_path); - } + apt_dir_layout_t *dir_layout = apt_dir_layout_create_ext(APT_LAYOUT_DIR_COUNT,pool); + + apt_dir_layout_path_set(dir_layout,APT_LAYOUT_CONF_DIR,conf_dir_path,pool); + apt_dir_layout_path_set(dir_layout,APT_LAYOUT_PLUGIN_DIR,plugin_dir_path,pool); + apt_dir_layout_path_set(dir_layout,APT_LAYOUT_LOG_DIR,log_dir_path,pool); + apt_dir_layout_path_set(dir_layout,APT_LAYOUT_DATA_DIR,data_dir_path,pool); + apt_dir_layout_path_set(dir_layout,APT_LAYOUT_VAR_DIR,log_dir_path,pool); + return dir_layout; } -APT_DECLARE(char*) apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool) +static apt_bool_t apt_dir_entry_id_by_label(const char **labels, apr_size_t count, const char *name, apr_size_t *id) { - if(dir_layout && dir_layout->data_dir_path && file_name) { - char *file_path = NULL; - if(apr_filepath_merge(&file_path,dir_layout->data_dir_path,file_name,0,pool) == APR_SUCCESS) { - return file_path; + apr_size_t i; + for(i=0; ifirst_cdata.first || !elem->first_cdata.first->text) { + return NULL; + } + + path = apr_pstrdup(pool,elem->first_cdata.first->text); + apr_collapse_spaces(path,path); + + /* Check if path is absolute or relative */ + status = apt_dir_is_path_absolute(path,pool); + if(status == APR_SUCCESS) { + /* Absolute path specified */ + return path; + } + else if (status == APR_ERELATIVE) { + /* Relative path specified -> merge it with the root path */ + if(apr_filepath_merge(&full_path,root_dir_path,path,APR_FILEPATH_NATIVE,pool) == APR_SUCCESS) { + return full_path; + } + } + + /* WARNING: invalid path specified */ + return NULL; +} + +APT_DECLARE(apt_bool_t) apt_dir_layout_load(apt_dir_layout_t *dir_layout, const char *config_file, apr_pool_t *pool) +{ + return apt_dir_layout_load_ext(dir_layout,config_file,default_labels,APT_LAYOUT_DIR_COUNT,pool); +} + +APT_DECLARE(apt_bool_t) apt_dir_layout_load_ext(apt_dir_layout_t *dir_layout, const char *config_file, const char **labels, apr_size_t count, apr_pool_t *pool) +{ + apr_xml_doc *doc; + const apr_xml_elem *elem; + const apr_xml_elem *root; + const apr_xml_attr *xml_attr; + char *path; + const char *root_dir_path = NULL; + apr_size_t id; + + if(!dir_layout || !config_file || !labels || !count) { + return FALSE; + } + + /* Parse XML document */ + doc = apt_dir_layout_doc_parse(config_file,pool); + if(!doc) { + return FALSE; + } + + root = doc->root; + + /* Match document name */ + if(!root || strcasecmp(root->name,"dirlayout") != 0) { + /* Unknown document */ + return FALSE; + } + + /* Find rootdir attribute */ + for(xml_attr = root->attr; xml_attr; xml_attr = xml_attr->next) { + if(strcasecmp(xml_attr->name, "rootdir") == 0) { + root_dir_path = xml_attr->value; + break; + } + } + + if(root_dir_path) { + /* If root dir path is specified, check if it is absolute or relative */ + apr_status_t status = apt_dir_is_path_absolute(root_dir_path,pool); + if(status == APR_ERELATIVE) { + /* Relative path specified -> make it absolute */ + char *full_path; + char *cur_dir_path; + /* Get the current directory */ + if(apr_filepath_get(&cur_dir_path,APR_FILEPATH_NATIVE,pool) != APR_SUCCESS) + return FALSE; + + /* Merge it with path specified */ + if(apr_filepath_merge(&full_path,cur_dir_path,root_dir_path,APR_FILEPATH_NATIVE,pool) != APR_SUCCESS) + return FALSE; + root_dir_path = full_path; + } + } + else { + /* If root dir path is not specified, get the default one */ + root_dir_path = apt_default_root_dir_path_get(pool); + } + + /* Navigate through document */ + for(elem = root->first_child; elem; elem = elem->next) { + if(apt_dir_entry_id_by_label(labels,dir_layout->count,elem->name,&id) == TRUE) { + path = apt_dir_layout_subdir_parse(root_dir_path,elem,pool); + if(path) { + apt_dir_layout_path_set_internal(dir_layout,id,path); + } + } + else { + /* Unknown element */ + } + } + return TRUE; +} + +APT_DECLARE(apt_bool_t) apt_dir_layout_path_set(apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *path, apr_pool_t *pool) +{ + if(!dir_layout || dir_entry_id >= dir_layout->count || !path) + return FALSE; + + dir_layout->paths[dir_entry_id] = apr_pstrdup(pool,path); + return TRUE; +} + +APT_DECLARE(const char*) apt_dir_layout_path_get(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id) +{ + if(!dir_layout || dir_entry_id >= dir_layout->count) + return NULL; + + return dir_layout->paths[dir_entry_id]; +} + +APT_DECLARE(char*) apt_dir_layout_path_compose(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *file_name, apr_pool_t *pool) +{ + char *file_path; + if(!dir_layout || dir_entry_id >= dir_layout->count) + return NULL; + + if(apr_filepath_merge(&file_path,dir_layout->paths[dir_entry_id],file_name,APR_FILEPATH_NATIVE,pool) == APR_SUCCESS) { + return file_path; + } return NULL; } APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool) { - if(dir_layout && dir_layout->conf_dir_path && file_name) { - char *file_path = NULL; - if(apr_filepath_merge(&file_path,dir_layout->conf_dir_path,file_name,0,pool) == APR_SUCCESS) { - return file_path; - } - } - return NULL; + return apt_dir_layout_path_compose(dir_layout,APT_LAYOUT_CONF_DIR,file_name,pool); +} + +APT_DECLARE(char*) apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool) +{ + return apt_dir_layout_path_compose(dir_layout,APT_LAYOUT_DATA_DIR,file_name,pool); +} + +APT_DECLARE(char*) apt_vardir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool) +{ + return apt_dir_layout_path_compose(dir_layout,APT_LAYOUT_VAR_DIR,file_name,pool); } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_header_field.c b/libs/unimrcp/libs/apr-toolkit/src/apt_header_field.c index 9cf814549f..a00fcb5ec5 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_header_field.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_header_field.c @@ -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: apt_header_field.c 1685 2010-05-06 05:34:54Z achaloyan $ + * $Id: apt_header_field.c 2223 2014-11-12 00:37:40Z achaloyan@gmail.com $ */ #include "apt_header_field.h" @@ -83,9 +83,13 @@ APT_DECLARE(apt_header_field_t*) apt_header_field_create_from_line(const apt_str apt_string_copy(&header_field->name,&item,pool); /* read value */ - apt_text_field_read(&stream,0,TRUE,&item); - apt_string_copy(&header_field->value,&item,pool); - + if(apt_text_field_read(&stream,0,TRUE,&item) == TRUE) { + apt_string_copy(&header_field->value,&item,pool); + } + else { + apt_string_reset(&header_field->value); + } + header_field->id = UNKNOWN_HEADER_FIELD_ID; APR_RING_ELEM_INIT(header_field,link); return header_field; diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_log.c b/libs/unimrcp/libs/apr-toolkit/src/apt_log.c index 10b374d957..844946cf46 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_log.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_log.c @@ -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: apt_log.c 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: apt_log.c 2198 2014-10-16 01:41:19Z achaloyan@gmail.com $ */ #include @@ -284,7 +284,7 @@ APT_DECLARE(apt_bool_t) apt_log_output_mode_check(apt_log_output_e mode) if(!apt_logger) { return FALSE; } - return (apt_logger->mode | mode) ? TRUE : FALSE; + return (apt_logger->mode & mode) ? TRUE : FALSE; } APT_DECLARE(int) apt_log_output_mode_translate(char *str) @@ -376,7 +376,7 @@ APT_DECLARE(apt_bool_t) apt_log_masking_set(apt_log_masking_e masking) return TRUE; } -APT_DECLARE(apt_log_masking_e) apt_log_masking_get() +APT_DECLARE(apt_log_masking_e) apt_log_masking_get(void) { if(!apt_logger) { return APT_LOG_MASKING_NONE; @@ -456,7 +456,24 @@ APT_DECLARE(apt_bool_t) apt_obj_log(const char *file, int line, apt_log_priority return status; } -static APR_INLINE unsigned long apt_thread_id_get() +APT_DECLARE(apt_bool_t) apt_va_log(const char *file, int line, apt_log_priority_e priority, const char *format, va_list arg_ptr) +{ + apt_bool_t status = TRUE; + if(!apt_logger) { + return FALSE; + } + if(priority <= apt_logger->priority) { + if(apt_logger->ext_handler) { + status = apt_logger->ext_handler(file,line,NULL,priority,format,arg_ptr); + } + else { + status = apt_do_log(file,line,priority,format,arg_ptr); + } + } + return status; +} + +static APR_INLINE unsigned long apt_thread_id_get(void) { #ifdef WIN32 return (unsigned long) GetCurrentThreadId(); @@ -514,8 +531,14 @@ static apt_bool_t apt_do_log(const char *file, int line, apt_log_priority_e prio static const char* apt_log_file_path_make(apt_log_file_data_t *file_data) { char *log_file_path = NULL; - const char *log_file_name = apr_psprintf(file_data->pool,"%s-%"APR_SIZE_T_FMT".log",file_data->log_file_name,file_data->cur_file_index); - apr_filepath_merge(&log_file_path,file_data->log_dir_path,log_file_name,0,file_data->pool); + const char *log_file_name = apr_psprintf(file_data->pool,"%s-%.2"APR_SIZE_T_FMT".log", + file_data->log_file_name, + file_data->cur_file_index); + apr_filepath_merge(&log_file_path, + file_data->log_dir_path, + log_file_name, + APR_FILEPATH_NATIVE, + file_data->pool); return log_file_path; } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_multipart_content.c b/libs/unimrcp/libs/apr-toolkit/src/apt_multipart_content.c index 3f3690ff7a..46254723ab 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_multipart_content.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_multipart_content.c @@ -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: apt_multipart_content.c 1673 2010-04-28 20:45:47Z achaloyan $ + * $Id: apt_multipart_content.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_net.c b/libs/unimrcp/libs/apr-toolkit/src/apt_net.c index e8da32a5b4..398c71a99c 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_net.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_net.c @@ -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,18 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: apt_net.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_net.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include #include "apt_net.h" +#include "apt_log.h" /** Get the IP address (in numeric address string format) by hostname */ apt_bool_t apt_ip_get(char **addr, apr_pool_t *pool) { apr_sockaddr_t *sockaddr = NULL; - char *hostname = apr_palloc(pool,APRMAXHOSTLEN+1); - if(apr_gethostname(hostname,APRMAXHOSTLEN,pool) != APR_SUCCESS) { + char hostname[APRMAXHOSTLEN+1]; + if(apr_gethostname(hostname,sizeof(hostname),pool) != APR_SUCCESS) { return FALSE; } if(apr_sockaddr_info_get(&sockaddr,hostname,APR_INET,0,0,pool) != APR_SUCCESS) { @@ -36,6 +37,104 @@ apt_bool_t apt_ip_get(char **addr, apr_pool_t *pool) return TRUE; } +#ifdef WIN32 +#include +#pragma comment(lib, "IPHLPAPI.lib") +#else +#include +#include +#endif + +/** Get the IP address (in numeric address string format) by network interface name */ +apt_bool_t apt_ip_get_by_iface(const char *iface_name, char **addr, apr_pool_t *pool) +{ + apt_bool_t status = FALSE; +#ifdef WIN32 + /* See the usage of GetAdaptersInfo(). + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa366314%28v=vs.85%29.aspx + */ + IP_ADAPTER_INFO *pAdapterInfo; + PIP_ADAPTER_INFO pAdapter; + ULONG ulOutBufLen; + DWORD dwRetVal; + + pAdapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof(IP_ADAPTER_INFO)); + ulOutBufLen = sizeof(IP_ADAPTER_INFO); + + /* Make an initial call to GetAdaptersInfo to get the size needed into the ulOutBufLen variable. */ + if(GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) != ERROR_SUCCESS) { + free(pAdapterInfo); + pAdapterInfo = (IP_ADAPTER_INFO *) malloc(ulOutBufLen); + } + + /* Make a second call to GetAdaptersInfo, passing pAdapterInfo and ulOutBufLen as parameters. */ + if((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) != ERROR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Adapters Info %d", dwRetVal); + return FALSE; + } + + /* Walk through linked list, maintaining head pointer. */ + pAdapter = pAdapterInfo; + while(pAdapter) { + /* Match human readable description with specified name. */ + if(strcasecmp(pAdapter->Description,iface_name) == 0) { + *addr = apr_pstrdup(pool,pAdapter->IpAddressList.IpAddress.String); + status = TRUE; + break; + } + + pAdapter = pAdapter->Next; + } + + if (pAdapterInfo) + free(pAdapterInfo); + +#else + + struct ifaddrs *ifaddr, *ifa; + int family, n; + char host[NI_MAXHOST]; + + if(getifaddrs(&ifaddr) == -1) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Interfaces"); + return FALSE; + } + + /* Walk through linked list, maintaining head pointer. */ + for(ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { + if(ifa->ifa_addr == NULL) continue; + + family = ifa->ifa_addr->sa_family; + if(family == AF_INET || family == AF_INET6) { + if(strcasecmp(ifa->ifa_name,iface_name) == 0) { + if(getnameinfo(ifa->ifa_addr, + (family == AF_INET) ? sizeof(struct sockaddr_in) : + sizeof(struct sockaddr_in6), + host, NI_MAXHOST, + NULL, 0, NI_NUMERICHOST) == 0) { + *addr = apr_pstrdup(pool,host); + status = TRUE; + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Name Info"); + } + break; + } + } + } + + freeifaddrs(ifaddr); +#endif + + if(status == TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Found Address %s by Interface [%s]", *addr, iface_name); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No Such Interface Found [%s]", iface_name); + } + return status; +} + /** Seconds from Jan 1 1900 to Jan 1 1970 */ #define NTP_TIME_OFFSET 2208988800UL diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c b/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c index af46ab7342..d6c866c0b6 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c @@ -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,22 +13,101 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: apt_nlsml_doc.c 1655 2010-04-16 18:36:27Z achaloyan $ + * $Id: apt_nlsml_doc.c 2177 2014-09-12 05:36:20Z achaloyan@gmail.com $ */ +#include +#ifdef WIN32 +#pragma warning(disable: 4127) +#endif +#include + #include "apt_nlsml_doc.h" #include "apt_log.h" +/** NLSML result */ +struct nlsml_result_t +{ + /** List of interpretations */ + APR_RING_HEAD(apt_ir_head_t, nlsml_interpretation_t) interpretations; + /** List of enrollment results */ + APR_RING_HEAD(apt_er_head_t, nlsml_enrollment_result_t) enrollment_results; + /** List of verification results */ + APR_RING_HEAD(apt_vr_head_t, nlsml_verification_result_t) verification_results; + + /** Optional grammar attribute */ + const char *grammar; +}; + +/** NLSML instance */ +struct nlsml_instance_t +{ + /** Ring entry */ + APR_RING_ENTRY(nlsml_instance_t) link; + + /** Instance element */ + apr_xml_elem *elem; +}; + +/** NLSML input */ +struct nlsml_input_t +{ + /** Input element */ + apr_xml_elem *elem; + /** Input mode attribute [default: "speech"] */ + const char *mode; + /** Confidence attribute [default: 1.0] */ + float confidence; + /** Timestamp-start attribute */ + const char *timestamp_start; + /** Timestamp-end attribute */ + const char *timestamp_end; +}; + +/** NLSML interpretation */ +struct nlsml_interpretation_t +{ + /** Ring entry */ + APR_RING_ENTRY(nlsml_interpretation_t) link; + + /** List of instances */ + APR_RING_HEAD(apt_head_t, nlsml_instance_t) instances; + /** Input [0..1] */ + nlsml_input_t *input; + + /** Confidence attribute [default: 1.0] */ + float confidence; + /** Optional grammar attribute */ + const char *grammar; +}; + +struct nlsml_enrollment_result_t +{ + /** Ring entry */ + APR_RING_ENTRY(nlsml_enrollment_result_t) link; +}; + +struct nlsml_verification_result_t +{ + /** Ring entry */ + APR_RING_ENTRY(nlsml_verification_result_t) link; +}; + /** Load NLSML document */ -APT_DECLARE(apr_xml_doc*) nlsml_doc_load(const apt_str_t *data, apr_pool_t *pool) +static apr_xml_doc* nlsml_doc_load(const char *data, apr_size_t length, apr_pool_t *pool) { apr_xml_parser *parser; apr_xml_doc *doc = NULL; const apr_xml_elem *root; + if(!data || !length) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No NLSML data available"); + return NULL; + } + /* create XML parser */ parser = apr_xml_parser_create(pool); - if(apr_xml_parser_feed(parser,data->buf,data->length) != APR_SUCCESS) { + if(apr_xml_parser_feed(parser,data,length) != APR_SUCCESS) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to feed NLSML input to the parser"); return NULL; } @@ -54,62 +133,437 @@ APT_DECLARE(apr_xml_doc*) nlsml_doc_load(const apt_str_t *data, apr_pool_t *pool return doc; } -/** Get the first element */ -APT_DECLARE(apr_xml_elem*) nlsml_first_interpret_get(const apr_xml_doc *doc) +/** Parse confidence value */ +static float nlsml_confidence_parse(const char *str) { - apr_xml_elem *child_elem; - for(child_elem = doc->root->first_child; child_elem; child_elem = child_elem->next) { - if(strcmp(child_elem->name,"interpretation") == 0) { - return child_elem; + float confidence = (float) atof(str); + if(confidence > 1.0) + confidence /= 100; + + return confidence; +} + +/** Parse element */ +static nlsml_instance_t* nlsml_instance_parse(apr_xml_elem *elem, apr_pool_t *pool) +{ + /* Initialize instance */ + nlsml_instance_t *instance = apr_palloc(pool, sizeof(*instance)); + APR_RING_ELEM_INIT(instance,link); + instance->elem = elem; + + return instance; +} + +/** Parse element */ +static nlsml_input_t* nlsml_input_parse(apr_xml_elem *elem, apr_pool_t *pool) +{ + const apr_xml_attr *xml_attr; + /* Initialize input */ + nlsml_input_t *input = apr_palloc(pool, sizeof(*input)); + input->elem = elem; + input->mode = "speech"; + input->confidence = 1.0; + input->timestamp_start = NULL; + input->timestamp_end = NULL; + + /* Find input attributes */ + for(xml_attr = elem->attr; xml_attr; xml_attr = xml_attr->next) { + if(strcasecmp(xml_attr->name, "mode") == 0) { + input->mode = xml_attr->value; + } + else if(strcasecmp(xml_attr->name, "confidence") == 0) { + input->confidence = nlsml_confidence_parse(xml_attr->value); + } + else if(strcasecmp(xml_attr->name, "timestamp-start") == 0) { + input->timestamp_start = xml_attr->value; + } + else if(strcasecmp(xml_attr->name, "timestamp-end") == 0) { + input->timestamp_end = xml_attr->value; + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown attribute '%s' for <%s>", xml_attr->name, elem->name); } } + return input; +} + +/** Parse element */ +static nlsml_interpretation_t* nlsml_interpretation_parse(apr_xml_elem *elem, apr_pool_t *pool) +{ + apr_xml_elem *child_elem; + const apr_xml_attr *xml_attr; + nlsml_instance_t *instance; + nlsml_input_t *input; + + /* Initialize interpretation */ + nlsml_interpretation_t *interpretation = apr_palloc(pool, sizeof(*interpretation)); + APR_RING_ELEM_INIT(interpretation,link); + interpretation->grammar = NULL; + interpretation->confidence = 1.0; + interpretation->input = NULL; + APR_RING_INIT(&interpretation->instances, nlsml_instance_t, link); + + /* Find optional grammar and confidence attributes */ + for(xml_attr = elem->attr; xml_attr; xml_attr = xml_attr->next) { + if(strcasecmp(xml_attr->name, "grammar") == 0) { + interpretation->grammar = xml_attr->value; + } + else if(strcasecmp(xml_attr->name, "confidence") == 0) { + interpretation->confidence = nlsml_confidence_parse(xml_attr->value); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown attribute '%s' for <%s>", xml_attr->name, elem->name); + } + } + + /* Find input and instance elements */ + for(child_elem = elem->first_child; child_elem; child_elem = child_elem->next) { + if(strcasecmp(child_elem->name, "input") == 0) { + input = nlsml_input_parse(child_elem, pool); + if(input) { + interpretation->input = input; + } + } + else if(strcasecmp(child_elem->name, "instance") == 0) { + instance = nlsml_instance_parse(child_elem, pool); + if(instance) { + APR_RING_INSERT_TAIL(&interpretation->instances, instance, nlsml_instance_t, link); + } + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown child element <%s> for <%s>", child_elem->name, elem->name); + } + } + + return interpretation; +} + +/** Parse element */ +static nlsml_enrollment_result_t* nlsml_enrollment_result_parse(const apr_xml_elem *elem, apr_pool_t *pool) +{ + /* To be done */ return NULL; } -/** Get the next element */ -APT_DECLARE(apr_xml_elem*) nlsml_next_interpret_get(const apr_xml_elem *elem) +/** Parse element */ +static nlsml_verification_result_t* nlsml_verification_result_parse(const apr_xml_elem *elem, apr_pool_t *pool) { - apr_xml_elem *child_elem; - for(child_elem = elem->next; child_elem; child_elem = child_elem->next) { - if(strcmp(child_elem->name,"interpretation") == 0) { - return child_elem; - } - } - + /* To be done */ return NULL; } -/** Get and elements of element */ -APT_DECLARE(apt_bool_t) nlsml_interpret_results_get(const apr_xml_elem *interpret, apr_xml_elem **instance, apr_xml_elem **input) +/** Parse NLSML result */ +APT_DECLARE(nlsml_result_t*) nlsml_result_parse(const char *data, apr_size_t length, apr_pool_t *pool) { + nlsml_result_t *result; + apr_xml_elem *root; apr_xml_elem *child_elem; - *input = NULL; - *instance = NULL; - for(child_elem = interpret->first_child; child_elem; child_elem = child_elem->next) { - if(strcmp(child_elem->name,"input") == 0) { - *input = child_elem; + const apr_xml_attr *xml_attr; + nlsml_interpretation_t *interpretation; + nlsml_enrollment_result_t *enrollment_result; + nlsml_verification_result_t *verification_result; + apr_xml_doc *doc; + /* Load XML document */ + doc = nlsml_doc_load(data, length, pool); + if(!doc) + return NULL; + + root = doc->root; + + /* Initialize result */ + result = apr_palloc(pool, sizeof(*result)); + APR_RING_INIT(&result->interpretations, nlsml_interpretation_t, link); + APR_RING_INIT(&result->enrollment_results, nlsml_enrollment_result_t, link); + APR_RING_INIT(&result->verification_results, nlsml_verification_result_t, link); + result->grammar = NULL; + + /* Find optional grammar attribute */ + for(xml_attr = root->attr; xml_attr; xml_attr = xml_attr->next) { + if(strcasecmp(xml_attr->name, "grammar") == 0) { + result->grammar = xml_attr->value; } - else if(strcmp(child_elem->name,"instance") == 0) { - *instance = child_elem; + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown attribute '%s' for <%s>", xml_attr->name, root->name); } } + + /* Find interpretation, enrollment-result, or verification-result elements */ + for(child_elem = root->first_child; child_elem; child_elem = child_elem->next) { + if(strcasecmp(child_elem->name, "interpretation") == 0) { + interpretation = nlsml_interpretation_parse(child_elem, pool); + if(interpretation) { + APR_RING_INSERT_TAIL(&result->interpretations, interpretation, nlsml_interpretation_t, link); + } + } + else if(strcasecmp(child_elem->name, "enrollment-result") == 0) { + enrollment_result = nlsml_enrollment_result_parse(child_elem, pool); + if(enrollment_result) { + APR_RING_INSERT_TAIL(&result->enrollment_results, enrollment_result, nlsml_enrollment_result_t, link); + } + } + else if(strcasecmp(child_elem->name, "verification-result") == 0) { + verification_result = nlsml_verification_result_parse(child_elem, pool); + if(verification_result) { + APR_RING_INSERT_TAIL(&result->verification_results, verification_result, nlsml_verification_result_t, link); + } + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown child element <%s> for <%s>", child_elem->name, root->name); + } + } + + if(APR_RING_EMPTY(&result->interpretations, nlsml_interpretation_t, link) && + APR_RING_EMPTY(&result->enrollment_results, nlsml_enrollment_result_t, link) && + APR_RING_EMPTY(&result->verification_results, nlsml_verification_result_t, link)) { + /* at least one of , , MUST be specified */ + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid NLSML document: at least one child element MUST be specified for <%s>", root->name); + } + + return result; +} + +/** Trace NLSML result (for debug purposes only) */ +APT_DECLARE(void) nlsml_result_trace(const nlsml_result_t *result, apr_pool_t *pool) +{ + int interpretation_count; + nlsml_interpretation_t *interpretation; + int instance_count; + nlsml_instance_t *instance; + nlsml_input_t *input; + const char *instance_data; + const char *input_data; + const char *timestamp_start; + const char *timestamp_end; + + if(result->grammar) + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Result.grammar: %s", result->grammar); + + interpretation_count = 0; + interpretation = nlsml_first_interpretation_get(result); + while(interpretation) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].confidence: %.2f", interpretation_count, nlsml_interpretation_confidence_get(interpretation)); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].grammar: %s", interpretation_count, nlsml_interpretation_grammar_get(interpretation)); + + instance_count = 0; + instance = nlsml_interpretation_first_instance_get(interpretation); + while(instance) { + nlsml_instance_swi_suppress(instance); + instance_data = nlsml_instance_content_generate(instance,pool); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].instance[%d]: %s", interpretation_count, instance_count, instance_data); + + instance_count++; + instance = nlsml_interpretation_next_instance_get(interpretation, instance); + } + + input = nlsml_interpretation_input_get(interpretation); + if(input) { + input_data = nlsml_input_content_generate(input,pool); + timestamp_start = nlsml_input_timestamp_start_get(input); + timestamp_end = nlsml_input_timestamp_end_get(input); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].input: %s", interpretation_count, input_data); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].input.mode: %s", interpretation_count, nlsml_input_mode_get(input)); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].input.confidence: %.2f", interpretation_count, nlsml_input_confidence_get(input)); + if(timestamp_start) + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].input.timestamp-start: %s", interpretation_count, timestamp_start); + if(timestamp_end) + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Interpretation[%d].input.timestamp-end: %s", interpretation_count, timestamp_end); + } + + interpretation_count++; + interpretation = nlsml_next_interpretation_get(result, interpretation); + } +} + +/** Get first interpretation */ +APT_DECLARE(nlsml_interpretation_t*) nlsml_first_interpretation_get(const nlsml_result_t *result) +{ + nlsml_interpretation_t *first_interpretation = APR_RING_FIRST(&result->interpretations); + if(first_interpretation == APR_RING_SENTINEL(&result->interpretations, nlsml_interpretation_t, link)) + return NULL; + return first_interpretation; +} + +/** Get next interpretation */ +APT_DECLARE(nlsml_interpretation_t*) nlsml_next_interpretation_get(const nlsml_result_t *result, const nlsml_interpretation_t *interpretation) +{ + nlsml_interpretation_t *next_interpretation = APR_RING_NEXT(interpretation, link); + if(next_interpretation == APR_RING_SENTINEL(&result->interpretations, nlsml_interpretation_t, link)) + return NULL; + return next_interpretation; +} + +/** Get first enrollment result */ +APT_DECLARE(nlsml_enrollment_result_t*) nlsml_first_enrollment_result_get(const nlsml_result_t *result) +{ + nlsml_enrollment_result_t *first_enrollment_result = APR_RING_FIRST(&result->enrollment_results); + if(first_enrollment_result == APR_RING_SENTINEL(&result->enrollment_results, nlsml_enrollment_result_t, link)) + return NULL; + return first_enrollment_result; +} + +/** Get next enrollment result */ +APT_DECLARE(nlsml_enrollment_result_t*) nlsml_next_enrollment_result_get(const nlsml_result_t *result, const nlsml_enrollment_result_t *enrollment_result) +{ + nlsml_enrollment_result_t *next_enrollment_result = APR_RING_NEXT(enrollment_result, link); + if(next_enrollment_result == APR_RING_SENTINEL(&result->enrollment_results, nlsml_enrollment_result_t, link)) + return NULL; + return next_enrollment_result; +} + +/** Get first verification result */ +APT_DECLARE(nlsml_verification_result_t*) nlsml_first_verification_result_get(const nlsml_result_t *result) +{ + nlsml_verification_result_t *first_verification_result = APR_RING_FIRST(&result->verification_results); + if(first_verification_result == APR_RING_SENTINEL(&result->verification_results, nlsml_verification_result_t, link)) + return NULL; + return first_verification_result; +} + +/** Get next verification result */ +APT_DECLARE(nlsml_verification_result_t*) nlsml_next_verification_result_get(const nlsml_result_t *result, const nlsml_verification_result_t *verification_result) +{ + nlsml_verification_result_t *next_verification_result = APR_RING_NEXT(verification_result, link); + if(next_verification_result == APR_RING_SENTINEL(&result->verification_results, nlsml_verification_result_t, link)) + return NULL; + return next_verification_result; +} + +/** Get grammar attribute of NLSML result */ +APT_DECLARE(const char*) nlsml_result_grammar_get(const nlsml_result_t *result) +{ + return result->grammar; +} + +/** Get first instance */ +APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_first_instance_get(const nlsml_interpretation_t *interpretation) +{ + nlsml_instance_t *first_instance = APR_RING_FIRST(&interpretation->instances); + if(first_instance == APR_RING_SENTINEL(&interpretation->instances, nlsml_instance_t, link)) + return NULL; + return first_instance; +} + +/** Get next instance */ +APT_DECLARE(nlsml_instance_t*) nlsml_interpretation_next_instance_get(const nlsml_interpretation_t *interpretation, const nlsml_instance_t *instance) +{ + nlsml_instance_t *next_instance = APR_RING_NEXT(instance, link); + if(next_instance == APR_RING_SENTINEL(&interpretation->instances, nlsml_instance_t, link)) + return NULL; + return next_instance; +} + +/** Get input */ +APT_DECLARE(nlsml_input_t*) nlsml_interpretation_input_get(const nlsml_interpretation_t *interpretation) +{ + return interpretation->input; +} + +/** Get interpretation confidence */ +APT_DECLARE(float) nlsml_interpretation_confidence_get(const nlsml_interpretation_t *interpretation) +{ + return interpretation->confidence; +} + +/** Get interpretation grammar */ +APT_DECLARE(const char*) nlsml_interpretation_grammar_get(const nlsml_interpretation_t *interpretation) +{ + return interpretation->grammar; +} + +/** Get instance element */ +APT_DECLARE(const apr_xml_elem*) nlsml_instance_elem_get(const nlsml_instance_t *instance) +{ + return instance->elem; +} + +/** Suppress SWI elements (normalize instance) */ +APT_DECLARE(apt_bool_t) nlsml_instance_swi_suppress(nlsml_instance_t *instance) +{ + apr_xml_elem *child_elem; + apr_xml_elem *prev_elem = NULL; + apr_xml_elem *swi_literal = NULL; + apt_bool_t remove; + if(!instance->elem) + return FALSE; + + for(child_elem = instance->elem->first_child; child_elem; child_elem = child_elem->next) { + remove = FALSE; + if(strcasecmp(child_elem->name,"SWI_literal") == 0) { + swi_literal = child_elem; + remove = TRUE; + } + else if(strcasecmp(child_elem->name,"SWI_meaning") == 0) { + remove = TRUE; + } + + if(remove == TRUE) { + if(child_elem == instance->elem->first_child) { + instance->elem->first_child = child_elem->next; + } + else if(prev_elem) { + prev_elem->next = child_elem->next; + } + } + + prev_elem = child_elem; + } + + if(APR_XML_ELEM_IS_EMPTY(instance->elem) && swi_literal) { + instance->elem->first_cdata = swi_literal->first_cdata; + } + return TRUE; } -/** Get specified atrribute of */ -APT_DECLARE(const char *) nlsml_input_attrib_get(const apr_xml_elem *input, const char *attrib, apt_bool_t recursive) +/** Generate a plain text content of the instance element */ +APT_DECLARE(const char*) nlsml_instance_content_generate(const nlsml_instance_t *instance, apr_pool_t *pool) { - const apr_xml_attr *xml_attr; - for(xml_attr = input->attr; xml_attr; xml_attr = xml_attr->next) { - if(strcasecmp(xml_attr->name,attrib) == 0) { - return xml_attr->value; - } + const char *buf = NULL; + if(instance->elem) { + apr_size_t size; + apr_xml_to_text(pool, instance->elem, APR_XML_X2T_INNER, NULL, NULL, &buf, &size); } - - if(recursive && input->parent) { - return nlsml_input_attrib_get(input->parent,attrib,recursive); - } - - return NULL; + return buf; +} + +/** Get input element */ +APT_DECLARE(const apr_xml_elem*) nlsml_input_elem_get(const nlsml_input_t *input) +{ + return input->elem; +} + +/** Generate a plain text content of the input element */ +APT_DECLARE(const char*) nlsml_input_content_generate(const nlsml_input_t *input, apr_pool_t *pool) +{ + const char *buf = NULL; + if(input->elem) { + apr_size_t size; + apr_xml_to_text(pool, input->elem, APR_XML_X2T_INNER, NULL, NULL, &buf, &size); + } + return buf; +} + +/** Get input mode */ +APT_DECLARE(const char*) nlsml_input_mode_get(const nlsml_input_t *input) +{ + return input->mode; +} + +/** Get input confidence */ +APT_DECLARE(float) nlsml_input_confidence_get(const nlsml_input_t *input) +{ + return input->confidence; +} + +/** Get start of input timestamp */ +APT_DECLARE(const char*) nlsml_input_timestamp_start_get(const nlsml_input_t *input) +{ + return input->timestamp_start; +} + +/** Get end of input timestamp */ +APT_DECLARE(const char*) nlsml_input_timestamp_end_get(const nlsml_input_t *input) +{ + return input->timestamp_end; } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_obj_list.c b/libs/unimrcp/libs/apr-toolkit/src/apt_obj_list.c index 69f006adee..83f64b0c71 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_obj_list.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_obj_list.c @@ -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: apt_obj_list.c 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_obj_list.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifdef WIN32 diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_pair.c b/libs/unimrcp/libs/apr-toolkit/src/apt_pair.c index 05c05c9e7e..d14ef5be98 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_pair.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_pair.c @@ -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: apt_pair.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_pair.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_pair.h" diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_poller_task.c b/libs/unimrcp/libs/apr-toolkit/src/apt_poller_task.c index 99a581667b..3a20231d20 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_poller_task.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_poller_task.c @@ -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: apt_poller_task.c 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_poller_task.c 2224 2014-11-12 00:41:45Z achaloyan@gmail.com $ */ #include "apt_poller_task.h" @@ -35,6 +35,11 @@ struct apt_poller_task_t { apt_cyclic_queue_t *msg_queue; apt_pollset_t *pollset; apt_timer_queue_t *timer_queue; + + apr_pollfd_t *desc_arr; + apr_int32_t desc_count; + apr_int32_t desc_index; + }; static apt_bool_t apt_poller_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg); @@ -87,6 +92,9 @@ APT_DECLARE(apt_poller_task_t*) apt_poller_task_create( apr_thread_mutex_create(&task->guard,APR_THREAD_MUTEX_UNNESTED,pool); task->timer_queue = apt_timer_queue_create(pool); + task->desc_arr = NULL; + task->desc_count = 0; + task->desc_index = 0; return task; } @@ -141,7 +149,7 @@ APT_DECLARE(apt_task_t*) apt_poller_task_base_get(const apt_poller_task_t *task) } /** Get task vtable */ -APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(apt_poller_task_t *task) +APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(const apt_poller_task_t *task) { return apt_task_vtable_get(task->base); } @@ -152,10 +160,29 @@ APT_DECLARE(void*) apt_poller_task_object_get(const apt_poller_task_t *task) return task->obj; } -/** Get pollset */ -APT_DECLARE(apt_pollset_t*) apt_poller_task_pollset_get(const apt_poller_task_t *task) +/** Add descriptor to pollset */ +APT_DECLARE(apt_bool_t) apt_poller_task_descriptor_add(const apt_poller_task_t *task, const apr_pollfd_t *descriptor) { - return task->pollset; + if(task->pollset) { + return apt_pollset_add(task->pollset,descriptor); + } + return FALSE; +} + +/** Remove descriptor from pollset */ +APT_DECLARE(apt_bool_t) apt_poller_task_descriptor_remove(const apt_poller_task_t *task, const apr_pollfd_t *descriptor) +{ + if(task->pollset) { + apr_int32_t i = task->desc_index + 1; + for(; i < task->desc_count; i++) { + apr_pollfd_t *cur_descriptor = &task->desc_arr[i]; + if(cur_descriptor->client_data == descriptor->client_data) { + cur_descriptor->client_data = NULL; + } + } + return apt_pollset_remove(task->pollset,descriptor); + } + return FALSE; } /** Create timer */ @@ -193,19 +220,16 @@ static apt_bool_t apt_poller_task_run(apt_task_t *base) apt_poller_task_t *task = apt_task_object_get(base); apt_bool_t *running; apr_status_t status; - apr_int32_t num; - const apr_pollfd_t *ret_pfd; apr_interval_time_t timeout; apr_uint32_t queue_timeout; apr_time_t time_now, time_last = 0; - int i; const char *task_name; if(!task) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Poller Task"); return FALSE; } - task_name = apt_task_name_get(task->base), + task_name = apt_task_name_get(task->base); running = apt_task_running_flag_get(task->base); if(!running) { @@ -217,7 +241,7 @@ static apt_bool_t apt_poller_task_run(apt_task_t *base) while(*running) { if(apt_timer_queue_timeout_get(task->timer_queue,&queue_timeout) == TRUE) { - timeout = queue_timeout * 1000; + timeout = (apr_interval_time_t)queue_timeout * 1000; time_last = apr_time_now(); apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s] timeout [%u]", task_name, queue_timeout); @@ -226,13 +250,14 @@ static apt_bool_t apt_poller_task_run(apt_task_t *base) timeout = -1; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s]",task_name); } - status = apt_pollset_poll(task->pollset, timeout, &num, &ret_pfd); + status = apt_pollset_poll(task->pollset, timeout, &task->desc_count, (const apr_pollfd_t **) &task->desc_arr); if(status != APR_SUCCESS && status != APR_TIMEUP) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Poll [%s] status: %d",task_name,status); continue; } - for(i = 0; i < num; i++) { - if(apt_pollset_is_wakeup(task->pollset,&ret_pfd[i])) { + for(task->desc_index = 0; task->desc_index < task->desc_count; task->desc_index++) { + const apr_pollfd_t *descriptor = &task->desc_arr[task->desc_index]; + if(apt_pollset_is_wakeup(task->pollset,descriptor)) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Poller Wakeup [%s]",task_name); apt_poller_task_wakeup_process(task); if(*running == FALSE) { @@ -242,7 +267,7 @@ static apt_bool_t apt_poller_task_run(apt_task_t *base) } apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Signalled Descriptor [%s]",task_name); - task->signal_handler(task->obj,&ret_pfd[i]); + task->signal_handler(task->obj,descriptor); } if(timeout != -1) { diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_pollset.c b/libs/unimrcp/libs/apr-toolkit/src/apt_pollset.c index 7592aff663..b7d8358d36 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_pollset.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_pollset.c @@ -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: apt_pollset.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_pollset.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_pool.c b/libs/unimrcp/libs/apr-toolkit/src/apt_pool.c index 8cbe247b9b..48ce662903 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_pool.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_pool.c @@ -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,13 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: apt_pool.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_pool.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_pool.h" +#include "apt_log.h" #define OWN_ALLOCATOR_PER_POOL +static int apt_abort_fn(int retcode) +{ + apt_log(APT_LOG_MARK,APT_PRIO_CRITICAL,"APR Abort Called [%d]", retcode); + return 0; +} + APT_DECLARE(apr_pool_t*) apt_pool_create() { apr_pool_t *pool = NULL; @@ -29,7 +36,7 @@ APT_DECLARE(apr_pool_t*) apt_pool_create() apr_thread_mutex_t *mutex = NULL; if(apr_allocator_create(&allocator) == APR_SUCCESS) { - if(apr_pool_create_ex(&pool,NULL,NULL,allocator) == APR_SUCCESS) { + if(apr_pool_create_ex(&pool,NULL,apt_abort_fn,allocator) == APR_SUCCESS) { apr_allocator_owner_set(allocator,pool); apr_thread_mutex_create(&mutex,APR_THREAD_MUTEX_NESTED,pool); apr_allocator_mutex_set(allocator,mutex); diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_string_table.c b/libs/unimrcp/libs/apr-toolkit/src/apt_string_table.c index bc96c51c49..5928e38c13 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_string_table.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_string_table.c @@ -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: apt_string_table.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_string_table.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_task.c b/libs/unimrcp/libs/apr-toolkit/src/apt_task.c index 5ce74e137f..83e04c963c 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_task.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_task.c @@ -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,13 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: apt_task.c 1696 2010-05-20 15:44:16Z achaloyan $ + * $Id: apt_task.c 2219 2014-11-11 02:35:14Z achaloyan@gmail.com $ */ +#ifdef WIN32 +#pragma warning(disable: 4127) +#endif +#include #include #include +#include #include "apt_task.h" -#include "apt_obj_list.h" #include "apt_log.h" /** Internal states of the task */ @@ -31,6 +35,10 @@ typedef enum { } apt_task_state_e; struct apt_task_t { + APR_RING_ENTRY(apt_task_t) link; /* entry to parent task ring */ + APR_RING_HEAD(apt_task_head_t, apt_task_t) head; /* head of child tasks ring */ + + const char *name; /* name of the task */ void *obj; /* external object associated with the task */ apr_pool_t *pool; /* memory pool to allocate task data from */ apt_task_msg_pool_t *msg_pool; /* message pool to allocate task messages from */ @@ -39,19 +47,33 @@ struct apt_task_t { apt_task_state_e state; /* current task state */ apt_task_vtable_t vtable; /* table of virtual methods */ apt_task_t *parent_task; /* parent (master) task */ - apt_obj_list_t *child_tasks; /* list of the child (slave) tasks */ apr_size_t pending_start; /* number of pending start requests */ apr_size_t pending_term; /* number of pending terminate requests */ + apr_size_t pending_off; /* number of pending taking-offline requests */ + apr_size_t pending_on; /* number of pending bringing-online requests */ apt_bool_t running; /* task is running (TRUE if even terminate has already been requested) */ apt_bool_t auto_ready; /* if TRUE, task is implicitly ready to process messages */ - const char *name; /* name of the task */ }; static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *data); static APR_INLINE void apt_task_vtable_reset(apt_task_vtable_t *vtable); + +static apt_bool_t apt_task_core_msg_signal(apt_task_t *task, apt_task_msg_pool_t *msg_pool, apt_core_task_msg_type_e type); + static apt_bool_t apt_task_terminate_request(apt_task_t *task); + +static apt_bool_t apt_task_start_process_internal(apt_task_t *task); +static apt_bool_t apt_task_terminate_process_internal(apt_task_t *task); +static apt_bool_t apt_task_offline_request_process(apt_task_t *task); +static apt_bool_t apt_task_online_request_process(apt_task_t *task); + +static apt_bool_t apt_task_offline_request_complete(apt_task_t *task); +static apt_bool_t apt_task_online_request_complete(apt_task_t *task); + static void apt_task_start_complete_raise(apt_task_t *task); static void apt_task_terminate_complete_raise(apt_task_t *task); +static void apt_task_offline_complete_raise(apt_task_t *task); +static void apt_task_online_complete_raise(apt_task_t *task); APT_DECLARE(apt_task_t*) apt_task_create( @@ -74,14 +96,20 @@ APT_DECLARE(apt_task_t*) apt_task_create( return NULL; } - /* reset and copy vtable */ + /* reset vtable */ apt_task_vtable_reset(&task->vtable); task->vtable.terminate = apt_task_terminate_request; + task->vtable.process_start = apt_task_start_process_internal; + task->vtable.process_terminate = apt_task_terminate_process_internal; + APR_RING_ELEM_INIT(task, link); + APR_RING_INIT(&task->head, apt_task_t, link); + task->parent_task = NULL; - task->child_tasks = apt_list_create(pool); task->pending_start = 0; task->pending_term = 0; + task->pending_off = 0; + task->pending_on = 0; task->auto_ready = TRUE; task->name = "Task"; return task; @@ -89,15 +117,9 @@ APT_DECLARE(apt_task_t*) apt_task_create( APT_DECLARE(apt_bool_t) apt_task_destroy(apt_task_t *task) { - apt_task_t *child_task = NULL; - apt_list_elem_t *elem = apt_list_first_elem_get(task->child_tasks); - /* walk through the list of the child tasks and destroy them */ - while(elem) { - child_task = apt_list_elem_object_get(elem); - if(child_task) { - apt_task_destroy(child_task); - } - elem = apt_list_next_elem_get(task->child_tasks,elem); + apt_task_t *child_task; + APR_RING_FOREACH(child_task, &task->head, apt_task_t, link) { + apt_task_destroy(child_task); } if(task->state != TASK_STATE_IDLE) { @@ -115,8 +137,12 @@ APT_DECLARE(apt_bool_t) apt_task_destroy(apt_task_t *task) APT_DECLARE(apt_bool_t) apt_task_add(apt_task_t *task, apt_task_t *child_task) { + if(!child_task) + return FALSE; + child_task->parent_task = task; - return (apt_list_push_back(task->child_tasks,child_task, child_task->pool) ? TRUE : FALSE); + APR_RING_INSERT_TAIL(&task->head,child_task,apt_task_t,link); + return TRUE; } APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task) @@ -128,7 +154,7 @@ APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task) task->state = TASK_STATE_START_REQUESTED; apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Start Task [%s]",task->name); if(task->vtable.start) { - /* raise virtual start method */ + /* invoke virtual start method */ task->vtable.start(task); } else { @@ -147,6 +173,16 @@ APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task) return status; } +APT_DECLARE(apt_bool_t) apt_task_offline(apt_task_t *task) +{ + return apt_task_core_msg_signal(task,task->msg_pool,CORE_TASK_MSG_TAKEOFFLINE_REQUEST); +} + +APT_DECLARE(apt_bool_t) apt_task_online(apt_task_t *task) +{ + return apt_task_core_msg_signal(task,task->msg_pool,CORE_TASK_MSG_BRINGONLINE_REQUEST); +} + APT_DECLARE(apt_bool_t) apt_task_terminate(apt_task_t *task, apt_bool_t wait_till_complete) { apt_bool_t status = FALSE; @@ -157,7 +193,7 @@ APT_DECLARE(apt_bool_t) apt_task_terminate(apt_task_t *task, apt_bool_t wait_til apr_thread_mutex_unlock(task->data_guard); if(task->state == TASK_STATE_TERMINATE_REQUESTED) { - /* raise virtual terminate method */ + /* invoke virtual terminate method */ apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Task [%s]",task->name); if(task->vtable.terminate) { status = task->vtable.terminate(task); @@ -226,11 +262,17 @@ APT_DECLARE(apt_task_msg_t*) apt_task_msg_get(apt_task_t *task) APT_DECLARE(apt_bool_t) apt_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Signal Message to [%s] [%d;%d]", - task->name, msg->type, msg->sub_type); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Signal Message to [%s] ["APT_PTR_FMT";%d;%d]", + task->name, msg, msg->type, msg->sub_type); if(task->vtable.signal_msg) { - return task->vtable.signal_msg(task,msg); + if(task->vtable.signal_msg(task,msg) == TRUE) { + return TRUE; + } } + + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Signal Task Message [%s] [0x%x;%d;%d]", + task->name, msg, msg->type, msg->sub_type); + apt_task_msg_release(msg); return FALSE; } @@ -238,35 +280,52 @@ APT_DECLARE(apt_bool_t) apt_task_msg_parent_signal(apt_task_t *task, apt_task_ms { apt_task_t *parent_task = task->parent_task; if(parent_task) { - if(parent_task->vtable.signal_msg) { - return parent_task->vtable.signal_msg(parent_task,msg); - } + return apt_task_msg_signal(parent_task,msg); } + + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Null Parent Task [%s]",task->name); + apt_task_msg_release(msg); return FALSE; } +static apt_bool_t apt_task_core_msg_signal(apt_task_t *task, apt_task_msg_pool_t *msg_pool, apt_core_task_msg_type_e type) +{ + if(task && msg_pool) { + apt_task_msg_t *msg = apt_task_msg_acquire(msg_pool); + /* signal core task message */ + msg->type = TASK_MSG_CORE; + msg->sub_type = type; + return apt_task_msg_signal(task,msg); + } + return FALSE; +} static apt_bool_t apt_core_task_msg_process(apt_task_t *task, apt_task_msg_t *msg) { switch(msg->sub_type) { case CORE_TASK_MSG_START_COMPLETE: - { apt_task_start_request_remove(task); break; - } case CORE_TASK_MSG_TERMINATE_REQUEST: - { - apt_task_child_terminate(task); - if(!task->pending_term) { - task->running = FALSE; + if(task->vtable.process_terminate) { + task->vtable.process_terminate(task); } break; - } case CORE_TASK_MSG_TERMINATE_COMPLETE: - { apt_task_terminate_request_remove(task); break; - } + case CORE_TASK_MSG_TAKEOFFLINE_REQUEST: + apt_task_offline_request_process(task); + break; + case CORE_TASK_MSG_TAKEOFFLINE_COMPLETE: + apt_task_offline_request_complete(task); + break; + case CORE_TASK_MSG_BRINGONLINE_REQUEST: + apt_task_online_request_process(task); + break; + case CORE_TASK_MSG_BRINGONLINE_COMPLETE: + apt_task_online_request_complete(task); + break; default: break; } return TRUE; @@ -275,8 +334,8 @@ static apt_bool_t apt_core_task_msg_process(apt_task_t *task, apt_task_msg_t *ms APT_DECLARE(apt_bool_t) apt_task_msg_process(apt_task_t *task, apt_task_msg_t *msg) { apt_bool_t status = FALSE; - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Message [%s] [%d;%d]", - task->name, msg->type, msg->sub_type); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Message [%s] ["APT_PTR_FMT";%d;%d]", + task->name, msg, msg->type, msg->sub_type); if(msg->type == TASK_MSG_CORE) { status = apt_core_task_msg_process(task,msg); } @@ -292,33 +351,21 @@ APT_DECLARE(apt_bool_t) apt_task_msg_process(apt_task_t *task, apt_task_msg_t *m static apt_bool_t apt_task_terminate_request(apt_task_t *task) { - if(task->msg_pool) { - apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool); - /* signal terminate-request message */ - msg->type = TASK_MSG_CORE; - msg->sub_type = CORE_TASK_MSG_TERMINATE_REQUEST; - return apt_task_msg_signal(task,msg); - } - return FALSE; + return apt_task_core_msg_signal(task,task->msg_pool,CORE_TASK_MSG_TERMINATE_REQUEST); } -APT_DECLARE(apt_bool_t) apt_task_child_start(apt_task_t *task) +APT_DECLARE(apt_bool_t) apt_task_start_request_process(apt_task_t *task) { - apt_task_t *child_task = NULL; - apt_list_elem_t *elem = apt_list_first_elem_get(task->child_tasks); - task->pending_start = 0; - if(task->vtable.on_start_request) { - task->vtable.on_start_request(task); - } - /* walk through the list of the child tasks and start them */ - while(elem) { - child_task = apt_list_elem_object_get(elem); - if(child_task) { - if(apt_task_start(child_task) == TRUE) { - task->pending_start++; - } + return apt_task_start_process_internal(task); +} + +static apt_bool_t apt_task_start_process_internal(apt_task_t *task) +{ + apt_task_t *child_task; + APR_RING_FOREACH(child_task, &task->head, apt_task_t, link) { + if(apt_task_start(child_task) == TRUE) { + task->pending_start++; } - elem = apt_list_next_elem_get(task->child_tasks,elem); } if(!task->pending_start) { @@ -328,36 +375,64 @@ APT_DECLARE(apt_bool_t) apt_task_child_start(apt_task_t *task) return TRUE; } -APT_DECLARE(apt_bool_t) apt_task_child_terminate(apt_task_t *task) +APT_DECLARE(apt_bool_t) apt_task_terminate_request_process(apt_task_t *task) { - apt_task_t *child_task = NULL; - apt_list_elem_t *elem = apt_list_first_elem_get(task->child_tasks); - task->pending_term = 0; - if(task->vtable.on_terminate_request) { - task->vtable.on_terminate_request(task); - } - /* walk through the list of the child tasks and terminate them */ - while(elem) { - child_task = apt_list_elem_object_get(elem); - if(child_task) { + return apt_task_terminate_process_internal(task); +} + +static apt_bool_t apt_task_terminate_process_internal(apt_task_t *task) +{ + apt_task_t *child_task; + APR_RING_FOREACH(child_task, &task->head, apt_task_t, link) { #ifdef ENABLE_SIMULT_TASK_TERMINATION - if(child_task->thread_handle) { - apr_thread_detach(child_task->thread_handle); - child_task->thread_handle = NULL; - } - if(apt_task_terminate(child_task,FALSE) == TRUE) { - task->pending_term++; - } -#else - apt_task_terminate(child_task,TRUE); -#endif + if(child_task->thread_handle) { + apr_thread_detach(child_task->thread_handle); + child_task->thread_handle = NULL; } - elem = apt_list_next_elem_get(task->child_tasks,elem); + if(apt_task_terminate(child_task,FALSE) == TRUE) { + task->pending_term++; + } +#else + apt_task_terminate(child_task,TRUE); +#endif } if(!task->pending_term) { /* no child task to terminate, just raise terminate-complete event */ apt_task_terminate_complete_raise(task); + task->running = FALSE; + } + return TRUE; +} + +static apt_bool_t apt_task_offline_request_process(apt_task_t *task) +{ + apt_task_t *child_task; + APR_RING_FOREACH(child_task, &task->head, apt_task_t, link) { + if(apt_task_offline(child_task) == TRUE) { + task->pending_off++; + } + } + + if(!task->pending_off) { + /* no child task, just raise offline-complete event */ + apt_task_offline_complete_raise(task); + } + return TRUE; +} + +static apt_bool_t apt_task_online_request_process(apt_task_t *task) +{ + apt_task_t *child_task; + APR_RING_FOREACH(child_task, &task->head, apt_task_t, link) { + if(apt_task_online(child_task) == TRUE) { + task->pending_on++; + } + } + + if(!task->pending_on) { + /* no child task, just raise online-complete event */ + apt_task_online_complete_raise(task); } return TRUE; } @@ -374,7 +449,9 @@ APT_DECLARE(apt_bool_t) apt_task_ready(apt_task_t *task) } /* start child tasks (if any) */ - apt_task_child_start(task); + if(task->vtable.process_start) { + task->vtable.process_start(task); + } return TRUE; } @@ -422,21 +499,39 @@ APT_DECLARE(apt_bool_t) apt_task_terminate_request_remove(apt_task_t *task) return TRUE; } +static apt_bool_t apt_task_offline_request_complete(apt_task_t *task) +{ + if(!task->pending_off) { + /* error case, no pending request */ + return FALSE; + } + task->pending_off--; + if(!task->pending_off) { + apt_task_offline_complete_raise(task); + } + return TRUE; +} + +static apt_bool_t apt_task_online_request_complete(apt_task_t *task) +{ + if(!task->pending_on) { + /* error case, no pending request */ + return FALSE; + } + task->pending_on--; + if(!task->pending_on) { + apt_task_online_complete_raise(task); + } + return TRUE; +} + static void apt_task_start_complete_raise(apt_task_t *task) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Task Started [%s]",task->name); if(task->vtable.on_start_complete) { task->vtable.on_start_complete(task); } - if(task->parent_task) { - if(task->msg_pool) { - apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool); - /* signal start-complete message */ - msg->type = TASK_MSG_CORE; - msg->sub_type = CORE_TASK_MSG_START_COMPLETE; - apt_task_msg_signal(task->parent_task,msg); - } - } + apt_task_core_msg_signal(task->parent_task,task->msg_pool,CORE_TASK_MSG_START_COMPLETE); } static void apt_task_terminate_complete_raise(apt_task_t *task) @@ -446,22 +541,35 @@ static void apt_task_terminate_complete_raise(apt_task_t *task) task->vtable.on_terminate_complete(task); } #ifdef ENABLE_SIMULT_TASK_TERMINATION - if(task->parent_task) { - if(task->msg_pool) { - apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool); - /* signal terminate-complete message */ - msg->type = TASK_MSG_CORE; - msg->sub_type = CORE_TASK_MSG_TERMINATE_COMPLETE; - apt_task_msg_signal(task->parent_task,msg); - } - } + apt_task_core_msg_signal(task->parent_task,task->msg_pool,CORE_TASK_MSG_TERMINATE_COMPLETE); #endif } +static void apt_task_offline_complete_raise(apt_task_t *task) +{ + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Task Taken Offline [%s]",task->name); + if(task->vtable.on_offline_complete) { + task->vtable.on_offline_complete(task); + } + apt_task_core_msg_signal(task->parent_task,task->msg_pool,CORE_TASK_MSG_TAKEOFFLINE_COMPLETE); +} + +static void apt_task_online_complete_raise(apt_task_t *task) +{ + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Task Brought Online [%s]",task->name); + if(task->vtable.on_online_complete) { + task->vtable.on_online_complete(task); + } + apt_task_core_msg_signal(task->parent_task,task->msg_pool,CORE_TASK_MSG_BRINGONLINE_COMPLETE); +} + static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *data) { apt_task_t *task = data; +#if APR_HAS_SETTHREADNAME + apr_thread_name_set(task->name); +#endif /* raise pre-run event */ if(task->vtable.on_pre_run) { task->vtable.on_pre_run(task); @@ -473,7 +581,9 @@ static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *dat if(task->auto_ready == TRUE) { /* start child tasks (if any) */ - apt_task_child_start(task); + if(task->vtable.process_start) { + task->vtable.process_start(task); + } } /* run task */ @@ -502,10 +612,12 @@ static APR_INLINE void apt_task_vtable_reset(apt_task_vtable_t *vtable) vtable->run = NULL; vtable->signal_msg = NULL; vtable->process_msg = NULL; + vtable->process_start = NULL; + vtable->process_terminate = NULL; vtable->on_pre_run = NULL; vtable->on_post_run = NULL; - vtable->on_start_request = NULL; vtable->on_start_complete = NULL; - vtable->on_terminate_request = NULL; vtable->on_terminate_complete = NULL; + vtable->on_offline_complete = NULL; + vtable->on_online_complete = NULL; } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_task_msg.c b/libs/unimrcp/libs/apr-toolkit/src/apt_task_msg.c index bb64cea6ef..d593e26eb0 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_task_msg.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_task_msg.c @@ -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: apt_task_msg.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: apt_task_msg.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_test_suite.c b/libs/unimrcp/libs/apr-toolkit/src/apt_test_suite.c index afaf29f0ce..4704235079 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_test_suite.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_test_suite.c @@ -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: apt_test_suite.c 1708 2010-05-24 17:03:25Z achaloyan $ + * $Id: apt_test_suite.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_pool.h" @@ -59,7 +59,7 @@ APT_DECLARE(void) apt_test_framework_destroy(apt_test_framework_t *framework) APT_DECLARE(apt_bool_t) apt_test_framework_suite_add(apt_test_framework_t *framework, apt_test_suite_t *suite) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Test Suite [%s]",suite->name); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Test Suite [%s]",suite->name.buf); return (apt_list_push_back(framework->suites,suite,suite->pool) ? TRUE : FALSE); } @@ -72,7 +72,7 @@ static apt_bool_t apt_test_framework_suite_run(apt_test_framework_t *framework, int argc, const char * const *argv) { apt_bool_t status = FALSE; - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"----- Run Test Suite [%s] -----",suite->name); + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"----- Run Test Suite [%s] -----",suite->name.buf); if(suite->tester) { status = suite->tester(suite,argc,argv); } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_text_message.c b/libs/unimrcp/libs/apr-toolkit/src/apt_text_message.c index 1e0d901b43..4a9db353df 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_text_message.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_text_message.c @@ -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: apt_text_message.c 1671 2010-04-28 19:50:29Z achaloyan $ + * $Id: apt_text_message.c 2218 2014-11-11 02:28:58Z achaloyan@gmail.com $ */ #include "apt_text_message.h" @@ -56,6 +56,7 @@ APT_DECLARE(apt_header_field_t*) apt_header_field_parse(apt_text_stream_t *strea apr_size_t folding_length = 0; apr_array_header_t *folded_lines = NULL; apt_header_field_t *header_field; + apt_str_t temp_line; apt_str_t *line; apt_pair_t pair; /* read name-value pair */ @@ -77,9 +78,11 @@ APT_DECLARE(apt_header_field_t*) apt_header_field_parse(apt_text_stream_t *strea if(!folded_lines) { folded_lines = apr_array_make(pool,1,sizeof(apt_str_t)); } - line = apr_array_push(folded_lines); - apt_text_line_read(stream,line); - folding_length += line->length; + if(apt_text_line_read(stream,&temp_line) == TRUE) { + line = apr_array_push(folded_lines); + *line = temp_line; + folding_length += line->length; + } }; header_field = apt_header_field_alloc(pool); @@ -97,7 +100,7 @@ APT_DECLARE(apt_header_field_t*) apt_header_field_parse(apt_text_stream_t *strea if(pair.value.length) { memcpy(header_field->value.buf, pair.value.buf, pair.value.length); } - + if(folding_length) { int i; char *pos = header_field->value.buf + pair.value.length; @@ -110,7 +113,7 @@ APT_DECLARE(apt_header_field_t*) apt_header_field_parse(apt_text_stream_t *strea } } header_field->value.buf[header_field->value.length] = '\0'; - + return header_field; } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_text_stream.c b/libs/unimrcp/libs/apr-toolkit/src/apt_text_stream.c index a15bbdb3cf..dccb0d4973 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_text_stream.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_text_stream.c @@ -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: apt_text_stream.c 1793 2011-01-10 21:46:14Z achaloyan $ + * $Id: apt_text_stream.c 2223 2014-11-12 00:37:40Z achaloyan@gmail.com $ */ #include @@ -273,8 +273,12 @@ static apt_bool_t apt_pair_parse(apt_pair_t *pair, const apt_str_t *field, apr_p apt_string_copy(&pair->name,&item,pool); /* read value */ - apt_text_field_read(&stream,';',TRUE,&item); - apt_string_copy(&pair->value,&item,pool); + if(apt_text_field_read(&stream,';',TRUE,&item) == TRUE) { + apt_string_copy(&pair->value,&item,pool); + } + else { + apt_string_reset(&pair->value); + } return TRUE; } @@ -300,28 +304,35 @@ APT_DECLARE(apt_bool_t) apt_pair_array_parse(apt_pair_arr_t *arr, const apt_str_ /** Generate array of name-value pairs */ APT_DECLARE(apt_bool_t) apt_pair_array_generate(const apt_pair_arr_t *arr, apt_str_t *str, apr_pool_t *pool) -{ - char buf[512]; - apt_text_stream_t stream; - apt_text_stream_init(&stream,buf,sizeof(buf)); - if(apt_text_pair_array_insert(&stream,arr) == FALSE) { - return FALSE; - } - apt_string_assign_n(str, stream.text.buf, stream.pos - stream.text.buf, pool); - return TRUE; -} - - -/** Insert array of name-value pairs */ -APT_DECLARE(apt_bool_t) apt_text_pair_array_insert(apt_text_stream_t *stream, const apt_pair_arr_t *arr) { int i; + char *pos; apt_pair_t *pair; - char *pos = stream->pos; - if(!arr) { + if(!arr || !str) { return FALSE; } + /* Compute length of string being generated */ + str->length = 0; + for(i=0; inelts; i++) { + pair = (apt_pair_t*)arr->elts + i; + /* name */ + str->length += pair->name.length; + if(pair->value.length) { + /* =value */ + str->length += 1 + pair->value.length; + } + } + if(arr->nelts) { + /* ; */ + str->length += arr->nelts - 1; + } + + /* Allocate required string */ + str->buf = apr_palloc(pool, str->length + 1); + + /* Copy pairs into allocated string */ + pos = str->buf; for(i=0; inelts; i++) { pair = (apt_pair_t*)arr->elts + i; if(i != 0) { @@ -337,7 +348,7 @@ APT_DECLARE(apt_bool_t) apt_text_pair_array_insert(apt_text_stream_t *stream, co } } } - stream->pos = pos; + *pos = '\0'; return TRUE; } @@ -374,26 +385,6 @@ APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_str_t * return TRUE; } -/** Generate boolean-value */ -APT_DECLARE(apt_bool_t) apt_boolean_value_insert(apt_text_stream_t *stream, apt_bool_t value) -{ - if(value == TRUE) { - if(stream->pos + TOKEN_TRUE_LENGTH >= stream->end) { - return FALSE; - } - memcpy(stream->pos,TOKEN_TRUE,TOKEN_TRUE_LENGTH); - stream->pos += TOKEN_TRUE_LENGTH; - } - else { - if(stream->pos + TOKEN_FALSE_LENGTH >= stream->end) { - return FALSE; - } - memcpy(stream->pos,TOKEN_FALSE,TOKEN_FALSE_LENGTH); - stream->pos += TOKEN_FALSE_LENGTH; - } - return TRUE; -} - /** Parse size_t value */ APT_DECLARE(apr_size_t) apt_size_value_parse(const apt_str_t *str) @@ -512,19 +503,21 @@ APT_DECLARE(apt_bool_t) apt_var_length_value_generate(apr_size_t *value, apr_siz /** Generate completion-cause */ APT_DECLARE(apt_bool_t) apt_completion_cause_generate(const apt_str_table_item_t table[], apr_size_t size, apr_size_t cause, apt_str_t *str, apr_pool_t *pool) { - char buf[256]; - int length; const apt_str_t *name = apt_string_table_str_get(table,size,cause); if(!name) { return FALSE; } - length = sprintf(buf,"%03"APR_SIZE_T_FMT" ",cause); - if(length <= 0) { + + /* 3 digits + 1 space + name->length */ + str->length = 4 + name->length; + str->buf = apr_palloc(pool,str->length + 1); + + if(sprintf(str->buf,"%03"APR_SIZE_T_FMT" ",cause) != 4) { return FALSE; } - memcpy(buf+length,name->buf,name->length); - apt_string_assign_n(str,buf,name->length + length,pool); + memcpy(str->buf+4,name->buf,name->length); + str->buf[str->length] = '\0'; return TRUE; } diff --git a/libs/unimrcp/libs/apr-toolkit/src/apt_timer_queue.c b/libs/unimrcp/libs/apr-toolkit/src/apt_timer_queue.c index 8d1b007b8c..05638260b9 100644 --- a/libs/unimrcp/libs/apr-toolkit/src/apt_timer_queue.c +++ b/libs/unimrcp/libs/apr-toolkit/src/apt_timer_queue.c @@ -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: apt_timer_queue.c 1665 2010-04-25 05:03:26Z achaloyan $ + * $Id: apt_timer_queue.c 2174 2014-09-12 03:33:16Z achaloyan@gmail.com $ */ #ifdef WIN32 @@ -48,6 +48,8 @@ struct apt_timer_t { void *obj; }; +static apt_bool_t apt_timer_insert(apt_timer_queue_t *timer_queue, apt_timer_t *timer); +static apt_bool_t apt_timer_remove(apt_timer_queue_t *timer_queue, apt_timer_t *timer); static void apt_timers_reschedule(apt_timer_queue_t *timer_queue); /** Create timer queue */ @@ -62,6 +64,7 @@ APT_DECLARE(apt_timer_queue_t*) apt_timer_queue_create(apr_pool_t *pool) /** Destroy timer queue */ APT_DECLARE(void) apt_timer_queue_destroy(apt_timer_queue_t *timer_queue) { + /* nothing to destroy */ } /** Advance scheduled timers */ @@ -77,7 +80,9 @@ APT_DECLARE(void) apt_timer_queue_advance(apt_timer_queue_t *timer_queue, apr_ui /* increment elapsed time */ timer_queue->elapsed_time += elapsed_time; if(timer_queue->elapsed_time >= 0xFFFF) { +#ifdef APT_TIMER_DEBUG apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Reschedule Timers [%u]",timer_queue->elapsed_time); +#endif apt_timers_reschedule(timer_queue); } @@ -90,8 +95,10 @@ APT_DECLARE(void) apt_timer_queue_advance(apt_timer_queue_t *timer_queue, apr_ui /* scheduled time is not elapsed yet */ break; } - + +#ifdef APT_TIMER_DEBUG apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Timer Elapsed 0x%x [%u]",timer,timer->scheduled_time); +#endif /* remove the elapsed timer from the list */ APR_RING_REMOVE(timer, link); timer->scheduled_time = 0; @@ -121,16 +128,16 @@ APT_DECLARE(apt_bool_t) apt_timer_queue_timeout_get(const apt_timer_queue_t *tim if(!timer) { return FALSE; } - + *timeout = timer->scheduled_time - timer_queue->elapsed_time; return TRUE; } - /** Create timer */ APT_DECLARE(apt_timer_t*) apt_timer_create(apt_timer_queue_t *timer_queue, apt_timer_proc_f proc, void *obj, apr_pool_t *pool) { apt_timer_t *timer = apr_palloc(pool,sizeof(apt_timer_t)); + APR_RING_ELEM_INIT(timer,link); timer->queue = timer_queue; timer->scheduled_time = 0; timer->proc = proc; @@ -138,7 +145,49 @@ APT_DECLARE(apt_timer_t*) apt_timer_create(apt_timer_queue_t *timer_queue, apt_t return timer; } -static APR_INLINE apt_bool_t apt_timer_insert(apt_timer_queue_t *timer_queue, apt_timer_t *timer) +/** Set one-shot timer */ +APT_DECLARE(apt_bool_t) apt_timer_set(apt_timer_t *timer, apr_uint32_t timeout) + +{ + apt_timer_queue_t *queue = timer->queue; + + if(timeout <= 0 || !timer->proc) { + return FALSE; + } + + if(timer->scheduled_time) { + /* remove timer first */ + apt_timer_remove(queue,timer); + } + + /* calculate time to elapse */ + timer->scheduled_time = queue->elapsed_time + timeout; +#ifdef APT_TIMER_DEBUG + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Set Timer 0x%x [%u]",timer,timer->scheduled_time); +#endif + if(APR_RING_EMPTY(&queue->head, apt_timer_t, link)) { + APR_RING_INSERT_TAIL(&queue->head,timer,apt_timer_t,link); + return TRUE; + } + + /* insert new node (timer) to sorted by scheduled time list */ + return apt_timer_insert(queue,timer); +} + +/** Kill timer */ +APT_DECLARE(apt_bool_t) apt_timer_kill(apt_timer_t *timer) +{ + if(!timer->scheduled_time) { + return FALSE; + } + +#ifdef APT_TIMER_DEBUG + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Kill Timer 0x%x [%u]",timer,timer->scheduled_time); +#endif + return apt_timer_remove(timer->queue,timer); +} + +static apt_bool_t apt_timer_insert(apt_timer_queue_t *timer_queue, apt_timer_t *timer) { apt_timer_t *it; for(it = APR_RING_LAST(&timer_queue->head); @@ -154,58 +203,27 @@ static APR_INLINE apt_bool_t apt_timer_insert(apt_timer_queue_t *timer_queue, ap return TRUE; } -/** Set one-shot timer */ -APT_DECLARE(apt_bool_t) apt_timer_set(apt_timer_t *timer, apr_uint32_t timeout) - +static apt_bool_t apt_timer_remove(apt_timer_queue_t *timer_queue, apt_timer_t *timer) { - apt_timer_queue_t *queue = timer->queue; - - if(timeout <= 0 || !timer->proc) { - return FALSE; - } - - /* calculate time to elapse */ - timer->scheduled_time = queue->elapsed_time + timeout; - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Set Timer 0x%x [%u]",timer,timer->scheduled_time); - - if(APR_RING_EMPTY(&queue->head, apt_timer_t, link)) { - APR_RING_INSERT_TAIL(&queue->head,timer,apt_timer_t,link); - return TRUE; - } - - /* insert new node (timer) to sorted by scheduled time list */ - return apt_timer_insert(queue,timer); -} - -/** Kill timer */ -APT_DECLARE(apt_bool_t) apt_timer_kill(apt_timer_t *timer) -{ - apt_timer_queue_t *queue = timer->queue; - - if(!timer->scheduled_time) { - return FALSE; - } - - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Kill Timer 0x%x [%u]",timer,timer->scheduled_time); /* remove node (timer) from the list */ APR_RING_REMOVE(timer,link); timer->scheduled_time = 0; - if(APR_RING_EMPTY(&queue->head, apt_timer_t, link)) { + if(APR_RING_EMPTY(&timer_queue->head, apt_timer_t, link)) { /* reset elapsed time if no timers set */ - queue->elapsed_time = 0; + timer_queue->elapsed_time = 0; } return TRUE; } -static void apt_timers_reschedule(apt_timer_queue_t *queue) +static void apt_timers_reschedule(apt_timer_queue_t *timer_queue) { apt_timer_t *it; - for(it = APR_RING_LAST(&queue->head); - it != APR_RING_SENTINEL(&queue->head, apt_timer_t, link); + for(it = APR_RING_LAST(&timer_queue->head); + it != APR_RING_SENTINEL(&timer_queue->head, apt_timer_t, link); it = APR_RING_PREV(it, link)) { - - it->scheduled_time -= queue->elapsed_time; + + it->scheduled_time -= timer_queue->elapsed_time; } - queue->elapsed_time = 0; + timer_queue->elapsed_time = 0; } diff --git a/libs/unimrcp/libs/mpf/Makefile.am b/libs/unimrcp/libs/mpf/Makefile.am index 15d97dcc14..f877596a41 100644 --- a/libs/unimrcp/libs/mpf/Makefile.am +++ b/libs/unimrcp/libs/mpf/Makefile.am @@ -1,9 +1,9 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mpf/codecs \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmpf.la @@ -21,6 +21,7 @@ include_HEADERS = codecs/g711/g711.h \ include/mpf_dtmf_detector.h \ include/mpf_dtmf_generator.h \ include/mpf_engine.h \ + include/mpf_engine_factory.h \ include/mpf_frame.h \ include/mpf_frame_buffer.h \ include/mpf_message.h \ @@ -62,6 +63,7 @@ libmpf_la_SOURCES = codecs/g711/g711.c \ src/mpf_dtmf_detector.c \ src/mpf_dtmf_generator.c \ src/mpf_engine.c \ + src/mpf_engine_factory.c \ src/mpf_mixer.c \ src/mpf_multiplier.c \ src/mpf_named_event.c \ diff --git a/libs/unimrcp/libs/mpf/codecs/g711/g711.c b/libs/unimrcp/libs/mpf/codecs/g711/g711.c index be9ab7b134..1d2a079152 100644 --- a/libs/unimrcp/libs/mpf/codecs/g711/g711.c +++ b/libs/unimrcp/libs/mpf/codecs/g711/g711.c @@ -14,27 +14,10 @@ * */ -/*! \file */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#ifndef _MSC_VER -#include -#ifdef HAVE_TGMATH_H -#include -#endif -#endif - #include "g711.h" /* Copied from the CCITT G.711 specification */ -static const uint8_t ulaw_to_alaw_table[256] = +static const apr_byte_t ulaw_to_alaw_table[256] = { 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, 58, 59, 56, 57, 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, @@ -56,8 +39,7 @@ static const uint8_t ulaw_to_alaw_table[256] = /* These transcoding tables are copied from the CCITT G.711 specification. To achieve optimal results, do not change them. */ - -static const uint8_t alaw_to_ulaw_table[256] = +static const apr_byte_t alaw_to_ulaw_table[256] = { 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, 57, 58, 55, 56, 61, 62, 59, 60, 49, 50, 47, 48, 53, 54, 51, 52, @@ -77,13 +59,13 @@ static const uint8_t alaw_to_ulaw_table[256] = 214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209 }; -uint8_t alaw_to_ulaw(uint8_t alaw) +apr_byte_t alaw_to_ulaw(apr_byte_t alaw) { return alaw_to_ulaw_table[alaw]; } /*- End of function --------------------------------------------------------*/ -uint8_t ulaw_to_alaw(uint8_t ulaw) +apr_byte_t ulaw_to_alaw(apr_byte_t ulaw) { return ulaw_to_alaw_table[ulaw]; } diff --git a/libs/unimrcp/libs/mpf/codecs/g711/g711.h b/libs/unimrcp/libs/mpf/codecs/g711/g711.h index ae7e0e44aa..3814dd79dc 100644 --- a/libs/unimrcp/libs/mpf/codecs/g711/g711.h +++ b/libs/unimrcp/libs/mpf/codecs/g711/g711.h @@ -14,9 +14,7 @@ * */ -/*! \file */ - -/*! \page g711_page A-law and mu-law handling +/* g711_page A-law and mu-law handling Lookup tables for A-law and u-law look attractive, until you consider the impact on the CPU cache. If it causes a substantial area of your processor cache to get hit too often, cache sloshing will severely slow things down. The main reason @@ -38,30 +36,23 @@ difficult to achieve the precise transcoding procedure laid down in the G.711 specification by other means. */ -#if !defined(_G711_H_) -#define _G711_H_ +#ifndef MPF_G711_H +#define MPF_G711_H -#ifdef __cplusplus -extern "C" { -#endif +/** + * @file g711.h + * @brief A-law and u-law conversion routines + */ -#ifdef _MSC_VER -#ifndef __inline__ -#define __inline__ __inline -#endif -#if !defined(_STDINT) && !defined(uint32_t) -typedef unsigned __int8 uint8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef unsigned __int16 uint16_t; -#endif -#endif +#include "mpf.h" + +APT_BEGIN_EXTERN_C #if defined(__i386__) /*! \brief Find the bit position of the highest set bit in a word \param bits The word to be searched \return The bit number of the highest set bit, or -1 if the word is zero. */ -static __inline__ int top_bit(unsigned int bits) +static APR_INLINE int top_bit(unsigned int bits) { int res; @@ -76,7 +67,7 @@ static __inline__ int top_bit(unsigned int bits) /*! \brief Find the bit position of the lowest set bit in a word \param bits The word to be searched \return The bit number of the lowest set bit, or -1 if the word is zero. */ -static __inline__ int bottom_bit(unsigned int bits) +static APR_INLINE int bottom_bit(unsigned int bits) { int res; @@ -88,7 +79,7 @@ static __inline__ int bottom_bit(unsigned int bits) } /*- End of function --------------------------------------------------------*/ #elif defined(__x86_64__) -static __inline__ int top_bit(unsigned int bits) +static APR_INLINE int top_bit(unsigned int bits) { int res; @@ -100,7 +91,7 @@ static __inline__ int top_bit(unsigned int bits) } /*- End of function --------------------------------------------------------*/ -static __inline__ int bottom_bit(unsigned int bits) +static APR_INLINE int bottom_bit(unsigned int bits) { int res; @@ -112,7 +103,7 @@ static __inline__ int bottom_bit(unsigned int bits) } /*- End of function --------------------------------------------------------*/ #else -static __inline__ int top_bit(unsigned int bits) +static APR_INLINE int top_bit(unsigned int bits) { int i; @@ -148,7 +139,7 @@ static __inline__ int top_bit(unsigned int bits) } /*- End of function --------------------------------------------------------*/ -static __inline__ int bottom_bit(unsigned int bits) +static APR_INLINE int bottom_bit(unsigned int bits) { int i; @@ -229,16 +220,16 @@ static __inline__ int bottom_bit(unsigned int bits) \param linear The sample to encode. \return The u-law value. */ -static __inline__ uint8_t linear_to_ulaw(int linear) +static APR_INLINE apr_byte_t linear_to_ulaw(int linear) { - uint8_t u_val; + apr_byte_t u_val; int mask; int seg; /* Get the sign and the magnitude of the value. */ if (linear < 0) { - linear = ULAW_BIAS - linear; + linear = ULAW_BIAS - linear - 1; mask = 0x7F; } else @@ -254,9 +245,9 @@ static __inline__ uint8_t linear_to_ulaw(int linear) * and complement the code word. */ if (seg >= 8) - u_val = (uint8_t) (0x7F ^ mask); + u_val = (apr_byte_t) (0x7F ^ mask); else - u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask); + u_val = (apr_byte_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask); #ifdef ULAW_ZEROTRAP /* Optional ITU trap */ if (u_val == 0) @@ -270,7 +261,7 @@ static __inline__ uint8_t linear_to_ulaw(int linear) \param ulaw The u-law sample to decode. \return The linear value. */ -static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) +static APR_INLINE apr_int16_t ulaw_to_linear(apr_byte_t ulaw) { int t; @@ -281,7 +272,7 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) * shift up by the segment number and subtract out the bias. */ t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4); - return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS)); + return (apr_int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS)); } /*- End of function --------------------------------------------------------*/ @@ -309,7 +300,7 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) \param linear The sample to encode. \return The A-law value. */ -static __inline__ uint8_t linear_to_alaw(int linear) +static APR_INLINE apr_byte_t linear_to_alaw(int linear) { int mask; int seg; @@ -323,7 +314,7 @@ static __inline__ uint8_t linear_to_alaw(int linear) { /* Sign (bit 7) bit = 0 */ mask = ALAW_AMI_MASK; - linear = -linear - 8; + linear = -linear - 1; } /* Convert the scaled magnitude to segment number. */ @@ -333,13 +324,15 @@ static __inline__ uint8_t linear_to_alaw(int linear) if (linear >= 0) { /* Out of range. Return maximum value. */ - return (uint8_t) (0x7F ^ mask); + return (apr_byte_t) (0x7F ^ mask); } +#if 0 /* This code is no longer reachable, since linear must be at least 0. */ /* We must be just a tiny step below zero */ - return (uint8_t) (0x00 ^ mask); + return (apr_byte_t) (0x00 ^ mask); +#endif } /* Combine the sign, segment, and quantization bits. */ - return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask); + return (apr_byte_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask); } /*- End of function --------------------------------------------------------*/ @@ -347,7 +340,7 @@ static __inline__ uint8_t linear_to_alaw(int linear) \param alaw The A-law sample to decode. \return The linear value. */ -static __inline__ int16_t alaw_to_linear(uint8_t alaw) +static APR_INLINE apr_int16_t alaw_to_linear(apr_byte_t alaw) { int i; int seg; @@ -359,7 +352,7 @@ static __inline__ int16_t alaw_to_linear(uint8_t alaw) i = (i + 0x108) << (seg - 1); else i += 8; - return (int16_t) ((alaw & 0x80) ? i : -i); + return (apr_int16_t) ((alaw & 0x80) ? i : -i); } /*- End of function --------------------------------------------------------*/ @@ -367,17 +360,15 @@ static __inline__ int16_t alaw_to_linear(uint8_t alaw) \param alaw The A-law sample to transcode. \return The best matching u-law value. */ -uint8_t alaw_to_ulaw(uint8_t alaw); +apr_byte_t alaw_to_ulaw(apr_byte_t alaw); /*! \brief Transcode from u-law to A-law, using the procedure defined in G.711. \param alaw The u-law sample to transcode. \return The best matching A-law value. */ -uint8_t ulaw_to_alaw(uint8_t ulaw); +apr_byte_t ulaw_to_alaw(apr_byte_t ulaw); -#ifdef __cplusplus -} -#endif +APT_END_EXTERN_C -#endif +#endif /* MPF_G711_H */ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/unimrcp/libs/mpf/include/mpf.h b/libs/unimrcp/libs/mpf/include/mpf.h index 66fbc37460..a435893595 100644 --- a/libs/unimrcp/libs/mpf/include/mpf.h +++ b/libs/unimrcp/libs/mpf/include/mpf.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: mpf.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_activity_detector.h b/libs/unimrcp/libs/mpf/include/mpf_activity_detector.h index 3bb17f64f9..fe2f15cec0 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_activity_detector.h +++ b/libs/unimrcp/libs/mpf/include/mpf_activity_detector.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: mpf_activity_detector.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_activity_detector.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_ACTIVITY_DETECTOR_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_audio_file_descriptor.h b/libs/unimrcp/libs/mpf/include/mpf_audio_file_descriptor.h index df1aa1fbcb..d7673004ea 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_audio_file_descriptor.h +++ b/libs/unimrcp/libs/mpf/include/mpf_audio_file_descriptor.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: mpf_audio_file_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_audio_file_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_AUDIO_FILE_DESCRIPTOR_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_audio_file_stream.h b/libs/unimrcp/libs/mpf/include/mpf_audio_file_stream.h index 0f936baddd..92da4bead0 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_audio_file_stream.h +++ b/libs/unimrcp/libs/mpf/include/mpf_audio_file_stream.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: mpf_audio_file_stream.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_audio_file_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_AUDIO_FILE_STREAM_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_bridge.h b/libs/unimrcp/libs/mpf/include/mpf_bridge.h index 3988e0bf3e..2cde68194d 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_bridge.h +++ b/libs/unimrcp/libs/mpf/include/mpf_bridge.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: mpf_bridge.h 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_bridge.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_BRIDGE_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_buffer.h b/libs/unimrcp/libs/mpf/include/mpf_buffer.h index ee0cc0121c..bb82f24ade 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_buffer.h +++ b/libs/unimrcp/libs/mpf/include/mpf_buffer.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: mpf_buffer.h 1709 2010-05-24 17:12:11Z achaloyan $ + * $Id: mpf_buffer.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_BUFFER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_codec.h b/libs/unimrcp/libs/mpf/include/mpf_codec.h index 817e1540ce..b34a53aaa0 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_codec.h +++ b/libs/unimrcp/libs/mpf/include/mpf_codec.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: mpf_codec.h 1686 2010-05-08 18:46:08Z achaloyan $ + * $Id: mpf_codec.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_CODEC_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_codec_descriptor.h b/libs/unimrcp/libs/mpf/include/mpf_codec_descriptor.h index 4958cada57..f4ed54e322 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_codec_descriptor.h +++ b/libs/unimrcp/libs/mpf/include/mpf_codec_descriptor.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: mpf_codec_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_codec_descriptor.h 2239 2014-11-12 01:52:59Z achaloyan@gmail.com $ */ #ifndef MPF_CODEC_DESCRIPTOR_H @@ -136,20 +136,20 @@ static APR_INLINE mpf_codec_descriptor_t* mpf_codec_descriptor_create(apr_pool_ /** Calculate encoded frame size in bytes */ static APR_INLINE apr_size_t mpf_codec_frame_size_calculate(const mpf_codec_descriptor_t *descriptor, const mpf_codec_attribs_t *attribs) { - return descriptor->channel_count * attribs->bits_per_sample * CODEC_FRAME_TIME_BASE * + return (size_t) descriptor->channel_count * attribs->bits_per_sample * CODEC_FRAME_TIME_BASE * descriptor->sampling_rate / 1000 / 8; /* 1000 - msec per sec, 8 - bits per byte */ } /** Calculate samples of the frame (ts) */ static APR_INLINE apr_size_t mpf_codec_frame_samples_calculate(const mpf_codec_descriptor_t *descriptor) { - return descriptor->channel_count * CODEC_FRAME_TIME_BASE * descriptor->sampling_rate / 1000; + return (size_t) descriptor->channel_count * CODEC_FRAME_TIME_BASE * descriptor->sampling_rate / 1000; } /** Calculate linear frame size in bytes */ static APR_INLINE apr_size_t mpf_codec_linear_frame_size_calculate(apr_uint16_t sampling_rate, apr_byte_t channel_count) { - return channel_count * BYTES_PER_SAMPLE * CODEC_FRAME_TIME_BASE * sampling_rate / 1000; + return (size_t) channel_count * BYTES_PER_SAMPLE * CODEC_FRAME_TIME_BASE * sampling_rate / 1000; } @@ -244,13 +244,13 @@ static APR_INLINE apt_bool_t mpf_codec_capabilities_merge(mpf_codec_capabilities static APR_INLINE apt_bool_t mpf_codec_capabilities_add(mpf_codec_capabilities_t *capabilities, int sample_rates, const char *codec_name) { mpf_codec_attribs_t *attribs = (mpf_codec_attribs_t*)apr_array_push(capabilities->attrib_arr); - apt_string_set(&attribs->name,codec_name); + apt_string_assign(&attribs->name,codec_name,capabilities->attrib_arr->pool); attribs->sample_rates = sample_rates; attribs->bits_per_sample = 0; return TRUE; } -/** Add default (liear PCM) capabilities */ +/** Add default (linear PCM) capabilities */ MPF_DECLARE(apt_bool_t) mpf_codec_default_capabilities_add(mpf_codec_capabilities_t *capabilities); /** Validate codec capabilities */ @@ -267,8 +267,8 @@ static APR_INLINE apt_bool_t mpf_codec_capabilities_validate(mpf_codec_capabilit /** Find matched descriptor in codec list */ MPF_DECLARE(mpf_codec_descriptor_t*) mpf_codec_list_descriptor_find(const mpf_codec_list_t *codec_list, const mpf_codec_descriptor_t *descriptor); -/** Modify codec list according to capabilities specified */ -MPF_DECLARE(apt_bool_t) mpf_codec_list_modify(mpf_codec_list_t *codec_list, const mpf_codec_capabilities_t *capabilities); +/** Match codec list with specified capabilities */ +MPF_DECLARE(apt_bool_t) mpf_codec_list_match(mpf_codec_list_t *codec_list, const mpf_codec_capabilities_t *capabilities); /** Intersect two codec lists */ MPF_DECLARE(apt_bool_t) mpf_codec_lists_intersect(mpf_codec_list_t *codec_list1, mpf_codec_list_t *codec_list2); diff --git a/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h b/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h index 44aaf2cfca..919d5112bb 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h +++ b/libs/unimrcp/libs/mpf/include/mpf_codec_manager.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: mpf_codec_manager.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_codec_manager.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_CODEC_MANAGER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_context.h b/libs/unimrcp/libs/mpf/include/mpf_context.h index 9190970a39..24e519ab81 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_context.h +++ b/libs/unimrcp/libs/mpf/include/mpf_context.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: mpf_context.h 1709 2010-05-24 17:12:11Z achaloyan $ + * $Id: mpf_context.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_CONTEXT_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_decoder.h b/libs/unimrcp/libs/mpf/include/mpf_decoder.h index 25402de6db..930b1dcb6b 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_decoder.h +++ b/libs/unimrcp/libs/mpf/include/mpf_decoder.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: mpf_decoder.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_decoder.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_DECODER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_encoder.h b/libs/unimrcp/libs/mpf/include/mpf_encoder.h index 5ef8366393..21e49120db 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_encoder.h +++ b/libs/unimrcp/libs/mpf/include/mpf_encoder.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: mpf_encoder.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_encoder.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_ENCODER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_engine.h b/libs/unimrcp/libs/mpf/include/mpf_engine.h index 0810c70700..4192ccf33b 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_engine.h +++ b/libs/unimrcp/libs/mpf/include/mpf_engine.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: mpf_engine.h 1709 2010-05-24 17:12:11Z achaloyan $ + * $Id: mpf_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_ENGINE_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_engine_factory.h b/libs/unimrcp/libs/mpf/include/mpf_engine_factory.h new file mode 100644 index 0000000000..d53607e2a4 --- /dev/null +++ b/libs/unimrcp/libs/mpf/include/mpf_engine_factory.h @@ -0,0 +1,48 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Id: mpf_engine_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ + */ + +#ifndef MPF_ENGINE_FACTORY_H +#define MPF_ENGINE_FACTORY_H + +/** + * @file mpf_engine.h + * @brief Factory of Media Processing Engines + */ + +#include "mpf_types.h" + +APT_BEGIN_EXTERN_C + +/** Create factory of media engines. */ +MPF_DECLARE(mpf_engine_factory_t*) mpf_engine_factory_create(apr_pool_t *pool); + +/** Add media engine to factory. */ +MPF_DECLARE(apt_bool_t) mpf_engine_factory_engine_add(mpf_engine_factory_t *mpf_factory, mpf_engine_t *media_engine); + +/** Determine whether factory is empty. */ +MPF_DECLARE(apt_bool_t) mpf_engine_factory_is_empty(const mpf_engine_factory_t *mpf_factory); + +/** Select next available media engine. */ +MPF_DECLARE(mpf_engine_t*) mpf_engine_factory_engine_select(mpf_engine_factory_t *mpf_factory); + +/** Associate media engines with RTP termination factory. */ +MPF_DECLARE(apt_bool_t) mpf_engine_factory_rtp_factory_assign(mpf_engine_factory_t *mpf_factory, mpf_termination_factory_t *rtp_factory); + +APT_END_EXTERN_C + +#endif /* MPF_ENGINE_FACTORY_H */ diff --git a/libs/unimrcp/libs/mpf/include/mpf_file_termination_factory.h b/libs/unimrcp/libs/mpf/include/mpf_file_termination_factory.h index de5bc30686..f1c9cbe99b 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_file_termination_factory.h +++ b/libs/unimrcp/libs/mpf/include/mpf_file_termination_factory.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: mpf_file_termination_factory.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_file_termination_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_FILE_TERMINATION_FACTORY_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_frame.h b/libs/unimrcp/libs/mpf/include/mpf_frame.h index f490f8b9ba..af37459962 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_frame.h +++ b/libs/unimrcp/libs/mpf/include/mpf_frame.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: mpf_frame.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_frame.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_FRAME_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_frame_buffer.h b/libs/unimrcp/libs/mpf/include/mpf_frame_buffer.h index 97d48d3dcb..749479fe22 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_frame_buffer.h +++ b/libs/unimrcp/libs/mpf/include/mpf_frame_buffer.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: mpf_frame_buffer.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_frame_buffer.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_FRAME_BUFFER_H @@ -47,6 +47,10 @@ apt_bool_t mpf_frame_buffer_write(mpf_frame_buffer_t *buffer, const mpf_frame_t /** Read frame from buffer */ apt_bool_t mpf_frame_buffer_read(mpf_frame_buffer_t *buffer, mpf_frame_t *frame); +#ifdef MPF_FRAME_BUFFER_DEBUG +apt_bool_t mpf_frame_buffer_file_open(mpf_frame_buffer_t *buffer, const char *utt_file_in, const char *utt_file_out); +#endif + APT_END_EXTERN_C #endif /* MPF_FRAME_BUFFER_H */ diff --git a/libs/unimrcp/libs/mpf/include/mpf_jitter_buffer.h b/libs/unimrcp/libs/mpf/include/mpf_jitter_buffer.h index 5bf142df43..5b483607fb 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_jitter_buffer.h +++ b/libs/unimrcp/libs/mpf/include/mpf_jitter_buffer.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: mpf_jitter_buffer.h 1802 2011-05-13 02:43:12Z achaloyan $ + * $Id: mpf_jitter_buffer.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_JITTER_BUFFER_H @@ -60,6 +60,9 @@ jb_result_t mpf_jitter_buffer_event_write(mpf_jitter_buffer_t *jb, const mpf_nam /** Read media frame from jitter buffer */ apt_bool_t mpf_jitter_buffer_read(mpf_jitter_buffer_t *jb, mpf_frame_t *media_frame); +/** Get current playout delay */ +apr_uint32_t mpf_jitter_buffer_playout_delay_get(const mpf_jitter_buffer_t *jb); + APT_END_EXTERN_C #endif /* MPF_JITTER_BUFFER_H */ diff --git a/libs/unimrcp/libs/mpf/include/mpf_message.h b/libs/unimrcp/libs/mpf/include/mpf_message.h index 95f4092df7..91db7f0946 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_message.h +++ b/libs/unimrcp/libs/mpf/include/mpf_message.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: mpf_message.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_message.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_MESSAGE_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_mixer.h b/libs/unimrcp/libs/mpf/include/mpf_mixer.h index a552634aa8..c4e66542d2 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_mixer.h +++ b/libs/unimrcp/libs/mpf/include/mpf_mixer.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: mpf_mixer.h 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_mixer.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_MIXER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_multiplier.h b/libs/unimrcp/libs/mpf/include/mpf_multiplier.h index 6e27e8b037..04d36469eb 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_multiplier.h +++ b/libs/unimrcp/libs/mpf/include/mpf_multiplier.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: mpf_multiplier.h 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_multiplier.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_MULTIPLIER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_named_event.h b/libs/unimrcp/libs/mpf/include/mpf_named_event.h index 1e4f04fdab..1ffc71fc2b 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_named_event.h +++ b/libs/unimrcp/libs/mpf/include/mpf_named_event.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: mpf_named_event.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_named_event.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_NAMED_EVENT_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_object.h b/libs/unimrcp/libs/mpf/include/mpf_object.h index cc48f4f879..2e8db829b5 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_object.h +++ b/libs/unimrcp/libs/mpf/include/mpf_object.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: mpf_object.h 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_object.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_OBJECT_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_resampler.h b/libs/unimrcp/libs/mpf/include/mpf_resampler.h index eeac10aaee..13e0e59143 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_resampler.h +++ b/libs/unimrcp/libs/mpf/include/mpf_resampler.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: mpf_resampler.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_resampler.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RESAMPLER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtcp_packet.h b/libs/unimrcp/libs/mpf/include/mpf_rtcp_packet.h index ba65d3f695..7afa55ede1 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtcp_packet.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtcp_packet.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: mpf_rtcp_packet.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtcp_packet.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTCP_PACKET_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_attribs.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_attribs.h index c5212d78e8..033e198851 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_attribs.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_attribs.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: mpf_rtp_attribs.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_attribs.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_ATTRIBS_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_defs.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_defs.h index 7d488db3ee..6ea541862a 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_defs.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_defs.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: mpf_rtp_defs.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_defs.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_DEFS_H @@ -32,16 +32,18 @@ APT_BEGIN_EXTERN_C /** Used to calculate actual number of received packets (32bit) in * case seq number (16bit) wrapped around */ #define RTP_SEQ_MOD (1 << 16) -/** Number of max dropout packets (seq numbers) is used to trigger drift - * in seq number or misorder packets */ +/** Number of max dropout packets (seq numbers) is used to trigger + * either a drift in the seq numbers or a misorder packet */ #define MAX_DROPOUT 3000 -/** Number of max misorder packets (seq numbers) to differentiate - * seq drift from misorder packets */ +/** Number of max misorder packets (seq numbers) is used to + * differentiate a drift in the seq numbers from a misorder packet */ #define MAX_MISORDER 100 -/** Restart receiver if threshold is fired */ +/** Restart receiver if threshold is reached */ #define DISCARDED_TO_RECEIVED_RATIO_THRESHOLD 30 /* 30% */ -/** Deviation threshold is used to trigger drift in timestamps */ +/** Deviation threshold is used to trigger a drift in timestamps */ #define DEVIATION_THRESHOLD 4000 +/** This threshold is used to detect a new talkspurt */ +#define INTER_TALKSPURT_GAP 1000 /* msec */ /** RTP receiver history declaration */ typedef struct rtp_rx_history_t rtp_rx_history_t; diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_descriptor.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_descriptor.h index 8412c8fc2a..60fac7aefa 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_descriptor.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_descriptor.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: mpf_rtp_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_DESCRIPTOR_H @@ -93,14 +93,16 @@ struct mpf_rtp_termination_descriptor_t { /** Jitter buffer configuration */ struct mpf_jb_config_t { - /** Min playout delay in msec (used in case of adaptive jitter buffer) */ - apr_size_t min_playout_delay; + /** Min playout delay in msec */ + apr_uint32_t min_playout_delay; /** Initial playout delay in msec */ - apr_size_t initial_playout_delay; - /** Max playout delay in msec (used in case of adaptive jitter buffer) */ - apr_size_t max_playout_delay; - /** Static - 0, adaptive - 1 jitter buffer */ + apr_uint32_t initial_playout_delay; + /** Max playout delay in msec */ + apr_uint32_t max_playout_delay; + /** Mode of operation of the jitter buffer: static - 0, adaptive - 1 */ apr_byte_t adaptive; + /** Enable/disable time skew detection */ + apr_byte_t time_skew_detection; }; /** RTCP BYE transmission policy */ @@ -164,6 +166,7 @@ static APR_INLINE void mpf_rtp_stream_descriptor_init(mpf_rtp_stream_descriptor_ descriptor->capabilities = NULL; descriptor->local = NULL; descriptor->remote = NULL; + descriptor->settings = NULL; } /** Initialize RTP termination descriptor */ @@ -180,6 +183,7 @@ static APR_INLINE void mpf_jb_config_init(mpf_jb_config_t *jb_config) jb_config->initial_playout_delay = 0; jb_config->min_playout_delay = 0; jb_config->max_playout_delay = 0; + jb_config->time_skew_detection = 1; } /** Allocate RTP config */ diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_header.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_header.h index a122cb6cc7..36c50c0b42 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_header.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_header.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: mpf_rtp_header.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_HEADER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_pt.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_pt.h index 27f88f1c7c..2d01346308 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_pt.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_pt.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: mpf_rtp_pt.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_pt.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_PT_H @@ -30,13 +30,15 @@ APT_BEGIN_EXTERN_C /** RTP payload types */ typedef enum { - RTP_PT_PCMU = 0, /**< PCMU Audio 8kHz 1 */ - RTP_PT_PCMA = 8, /**< PCMA Audio 8kHz 1 */ + RTP_PT_PCMU = 0, /**< PCMU Audio 8kHz 1 */ + RTP_PT_PCMA = 8, /**< PCMA Audio 8kHz 1 */ - RTP_PT_CN = 13, /**< Comfort Noise Audio 8kHz 1 */ + RTP_PT_CN = 13, /**< Comfort Noise Audio 8kHz 1 */ + + RTP_PT_RESERVED = 19, /**< Not used for any particular codec */ RTP_PT_DYNAMIC = 96, /**< Start of dynamic payload types */ - RTP_PT_DYNAMIC_MAX = 127, /**< End of dynamic payload types */ + RTP_PT_DYNAMIC_MAX = 127, /**< End of dynamic payload types */ RTP_PT_UNKNOWN = 128 /**< Unknown (invalid) payload type */ } mpf_rtp_pt_e; diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_stat.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_stat.h index e97b58c826..d312e75be5 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_stat.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_stat.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: mpf_rtp_stat.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_stat.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_STAT_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_stream.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_stream.h index 76ef8963a5..00e6baf557 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_stream.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_stream.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: mpf_rtp_stream.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_STREAM_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_rtp_termination_factory.h b/libs/unimrcp/libs/mpf/include/mpf_rtp_termination_factory.h index d34ffcbc3d..f639f261b9 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_rtp_termination_factory.h +++ b/libs/unimrcp/libs/mpf/include/mpf_rtp_termination_factory.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: mpf_rtp_termination_factory.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_termination_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_RTP_TERMINATION_FACTORY_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_scheduler.h b/libs/unimrcp/libs/mpf/include/mpf_scheduler.h index 1e83091b8e..fe8e79af46 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_scheduler.h +++ b/libs/unimrcp/libs/mpf/include/mpf_scheduler.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: mpf_scheduler.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_scheduler.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_SCHEDULER_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_stream.h b/libs/unimrcp/libs/mpf/include/mpf_stream.h index 93676b7eb0..33276aa7b7 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_stream.h +++ b/libs/unimrcp/libs/mpf/include/mpf_stream.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: mpf_stream.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_STREAM_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_stream_descriptor.h b/libs/unimrcp/libs/mpf/include/mpf_stream_descriptor.h index fbdeb5b068..d91f5166eb 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_stream_descriptor.h +++ b/libs/unimrcp/libs/mpf/include/mpf_stream_descriptor.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: mpf_stream_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_stream_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_STREAM_DESCRIPTOR_H diff --git a/libs/unimrcp/libs/mpf/include/mpf_termination.h b/libs/unimrcp/libs/mpf/include/mpf_termination.h index 8444f2edff..6d45aeeddb 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_termination.h +++ b/libs/unimrcp/libs/mpf/include/mpf_termination.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: mpf_termination.h 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_termination.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_TERMINATION_H @@ -57,8 +57,8 @@ struct mpf_termination_t { const char *name; /** External object */ void *obj; - /** Object to send events to */ - void *event_handler_obj; + /** Media engine to send events to */ + void *media_engine; /** Event handler */ mpf_termination_event_handler_f event_handler; /** Codec manager */ diff --git a/libs/unimrcp/libs/mpf/include/mpf_termination_factory.h b/libs/unimrcp/libs/mpf/include/mpf_termination_factory.h index 973044b888..08d46fc64f 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_termination_factory.h +++ b/libs/unimrcp/libs/mpf/include/mpf_termination_factory.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: mpf_termination_factory.h 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_termination_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_TERMINATION_FACTORY_H @@ -32,9 +32,18 @@ APT_BEGIN_EXTERN_C struct mpf_termination_factory_t { /** Virtual create */ mpf_termination_t* (*create_termination)(mpf_termination_factory_t *factory, void *obj, apr_pool_t *pool); + /** Virtual assign engine */ + apt_bool_t (*assign_engine)(mpf_termination_factory_t *factory, mpf_engine_t *media_engine); }; - +/** + * Assign media engine to termination factory. + * @param termination_factory the termination factory to assign media engine to + * @param media_engine the media engine to assign + */ +MPF_DECLARE(apt_bool_t) mpf_termination_factory_engine_assign( + mpf_termination_factory_t *termination_factory, + mpf_engine_t *media_engine); /** * Create MPF termination from termination factory. diff --git a/libs/unimrcp/libs/mpf/include/mpf_trace.h b/libs/unimrcp/libs/mpf/include/mpf_trace.h new file mode 100644 index 0000000000..323cc034ba --- /dev/null +++ b/libs/unimrcp/libs/mpf/include/mpf_trace.h @@ -0,0 +1,51 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Id: apt_log.h 1792 2011-01-10 21:08:52Z achaloyan $ + */ + +#ifndef MPF_TRACE_H +#define MPF_TRACE_H + +/** + * @file mpf_trace.h + * @brief MPF Tracer + */ + +#include +#include "mpf.h" + +APT_BEGIN_EXTERN_C + +#ifdef WIN32 +static void mpf_debug_output_trace(const char* format, ...) +{ + char buf[1024]; + va_list arg; + va_start(arg, format); + apr_vsnprintf(buf, sizeof(buf), format, arg); + va_end(arg); + + OutputDebugStringA(buf); +} +#else +static APR_INLINE void mpf_debug_output_trace() {} +#endif + +static APR_INLINE void mpf_null_trace() {} + +APT_END_EXTERN_C + +#endif /* MPF_TRACE_H */ diff --git a/libs/unimrcp/libs/mpf/include/mpf_types.h b/libs/unimrcp/libs/mpf/include/mpf_types.h index f3017489f6..3b8637eaba 100644 --- a/libs/unimrcp/libs/mpf/include/mpf_types.h +++ b/libs/unimrcp/libs/mpf/include/mpf_types.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: mpf_types.h 1543 2010-02-24 21:46:24Z achaloyan $ + * $Id: mpf_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MPF_TYPES_H @@ -31,6 +31,9 @@ APT_BEGIN_EXTERN_C /** Opaque MPF engine declaration */ typedef struct mpf_engine_t mpf_engine_t; +/** Opaque MPF engine factory declaration */ +typedef struct mpf_engine_factory_t mpf_engine_factory_t; + /** Opaque MPF scheduler declaration */ typedef struct mpf_scheduler_t mpf_scheduler_t; diff --git a/libs/unimrcp/libs/mpf/mpf.2008.vcproj b/libs/unimrcp/libs/mpf/mpf.2008.vcproj deleted file mode 100644 index 95b925ea59..0000000000 --- a/libs/unimrcp/libs/mpf/mpf.2008.vcproj +++ /dev/null @@ -1,559 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mpf/mpf.2010.vcxproj.filters b/libs/unimrcp/libs/mpf/mpf.2010.vcxproj.filters deleted file mode 100644 index 0e4bc84d13..0000000000 --- a/libs/unimrcp/libs/mpf/mpf.2010.vcxproj.filters +++ /dev/null @@ -1,239 +0,0 @@ - - - - - {3d69fc35-a195-4376-9508-ef77d7b27e71} - - - {81e2eace-c57a-4135-92cd-cc3575dfb088} - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {6fc3533a-b688-477d-914d-e0ffb15aa9a9} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - codecs\g711 - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - - - codecs\g711 - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - \ No newline at end of file diff --git a/libs/unimrcp/libs/mpf/mpf.2012.vcxproj b/libs/unimrcp/libs/mpf/mpf.2012.vcxproj deleted file mode 100644 index 9a8e7ed24b..0000000000 --- a/libs/unimrcp/libs/mpf/mpf.2012.vcxproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mpf - {B5A00BFA-6083-4FAE-A097-71642D6473B5} - mpf - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - false - ProgramDatabase - - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mpf/mpf.vcproj b/libs/unimrcp/libs/mpf/mpf.vcproj index b3fde36677..043486d580 100644 --- a/libs/unimrcp/libs/mpf/mpf.vcproj +++ b/libs/unimrcp/libs/mpf/mpf.vcproj @@ -1,544 +1,552 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/unimrcp/libs/mpf/mpf.2010.vcxproj b/libs/unimrcp/libs/mpf/mpf.vcxproj similarity index 78% rename from libs/unimrcp/libs/mpf/mpf.2010.vcxproj rename to libs/unimrcp/libs/mpf/mpf.vcxproj index 2a89b638c5..730174d4f8 100644 --- a/libs/unimrcp/libs/mpf/mpf.2010.vcxproj +++ b/libs/unimrcp/libs/mpf/mpf.vcxproj @@ -1,191 +1,200 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mpf - {B5A00BFA-6083-4FAE-A097-71642D6473B5} - mpf - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - false - ProgramDatabase - - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions) - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B5A00BFA-6083-4FAE-A097-71642D6473B5} + mpf + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + codecs;%(AdditionalIncludeDirectories) + + + + + codecs;%(AdditionalIncludeDirectories) + + + + + X64 + + + codecs;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + codecs;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {13deeca0-bdd4-4744-a1a2-8eb0a44df3d2} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mpf/mpf.2012.vcxproj.filters b/libs/unimrcp/libs/mpf/mpf.vcxproj.filters similarity index 93% rename from libs/unimrcp/libs/mpf/mpf.2012.vcxproj.filters rename to libs/unimrcp/libs/mpf/mpf.vcxproj.filters index 72d0db06fe..16ecf0e62f 100644 --- a/libs/unimrcp/libs/mpf/mpf.2012.vcxproj.filters +++ b/libs/unimrcp/libs/mpf/mpf.vcxproj.filters @@ -1,233 +1,239 @@ - - - - - {3d69fc35-a195-4376-9508-ef77d7b27e71} - - - {81e2eace-c57a-4135-92cd-cc3575dfb088} - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {6fc3533a-b688-477d-914d-e0ffb15aa9a9} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - codecs\g711 - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - - - codecs\g711 - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - + + + + + {33a3a10a-4697-4720-8c24-20340757326e} + + + {148f1b8f-859b-4dd9-96b0-0474d7bb875b} + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {35011b8a-6a42-4e9f-b55b-a84db1d929a8} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + codecs\g711 + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + + + codecs\g711 + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mpf/src/mpf_activity_detector.c b/libs/unimrcp/libs/mpf/src/mpf_activity_detector.c index bf3cd76fc6..09b1a813a3 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_activity_detector.c +++ b/libs/unimrcp/libs/mpf/src/mpf_activity_detector.c @@ -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: mpf_activity_detector.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_activity_detector.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_activity_detector.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_audio_file_stream.c b/libs/unimrcp/libs/mpf/src/mpf_audio_file_stream.c index c235da38de..5c168ebf00 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_audio_file_stream.c +++ b/libs/unimrcp/libs/mpf/src/mpf_audio_file_stream.c @@ -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: mpf_audio_file_stream.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_audio_file_stream.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_audio_file_stream.h" @@ -112,7 +112,8 @@ static const mpf_audio_stream_vtable_t vtable = { mpf_audio_file_frame_read, mpf_audio_file_writer_open, mpf_audio_file_writer_close, - mpf_audio_file_frame_write + mpf_audio_file_frame_write, + NULL /* mpf_audio_file_trace */ }; MPF_DECLARE(mpf_audio_stream_t*) mpf_file_stream_create(mpf_termination_t *termination, apr_pool_t *pool) diff --git a/libs/unimrcp/libs/mpf/src/mpf_bridge.c b/libs/unimrcp/libs/mpf/src/mpf_bridge.c index 25c12de2ff..0daf11caee 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_bridge.c +++ b/libs/unimrcp/libs/mpf/src/mpf_bridge.c @@ -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: mpf_bridge.c 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_bridge.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_bridge.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_buffer.c b/libs/unimrcp/libs/mpf/src/mpf_buffer.c index b253d6ae02..8db46d0a91 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_buffer.c +++ b/libs/unimrcp/libs/mpf/src/mpf_buffer.c @@ -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: mpf_buffer.c 1709 2010-05-24 17:12:11Z achaloyan $ + * $Id: mpf_buffer.c 2181 2014-09-14 04:29:38Z achaloyan@gmail.com $ */ #ifdef WIN32 @@ -85,10 +85,11 @@ static APR_INLINE mpf_chunk_t* mpf_buffer_chunk_read(mpf_buffer_t *buffer) apt_bool_t mpf_buffer_audio_write(mpf_buffer_t *buffer, void *data, apr_size_t size) { mpf_chunk_t *chunk; - apt_bool_t status = TRUE; + apt_bool_t status; apr_thread_mutex_lock(buffer->guard); chunk = apr_palloc(buffer->pool,sizeof(mpf_chunk_t)); + APR_RING_ELEM_INIT(chunk,link); chunk->frame.codec_frame.buffer = apr_palloc(buffer->pool,size); memcpy(chunk->frame.codec_frame.buffer,data,size); chunk->frame.codec_frame.size = size; @@ -103,10 +104,11 @@ apt_bool_t mpf_buffer_audio_write(mpf_buffer_t *buffer, void *data, apr_size_t s apt_bool_t mpf_buffer_event_write(mpf_buffer_t *buffer, mpf_frame_type_e event_type) { mpf_chunk_t *chunk; - apt_bool_t status = TRUE; + apt_bool_t status; apr_thread_mutex_lock(buffer->guard); chunk = apr_palloc(buffer->pool,sizeof(mpf_chunk_t)); + APR_RING_ELEM_INIT(chunk,link); chunk->frame.codec_frame.buffer = NULL; chunk->frame.codec_frame.size = 0; chunk->frame.type = event_type; diff --git a/libs/unimrcp/libs/mpf/src/mpf_codec_descriptor.c b/libs/unimrcp/libs/mpf/src/mpf_codec_descriptor.c index b493f4959b..ca9b903d26 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_codec_descriptor.c +++ b/libs/unimrcp/libs/mpf/src/mpf_codec_descriptor.c @@ -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: mpf_codec_descriptor.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_codec_descriptor.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_codec_descriptor.h" @@ -89,7 +89,6 @@ MPF_DECLARE(mpf_codec_descriptor_t*) mpf_codec_descriptor_create_by_capabilities return descriptor; } - /** Match two codec descriptors */ MPF_DECLARE(apt_bool_t) mpf_codec_descriptors_match(const mpf_codec_descriptor_t *descriptor1, const mpf_codec_descriptor_t *descriptor2) { @@ -116,7 +115,7 @@ MPF_DECLARE(apt_bool_t) mpf_codec_lpcm_descriptor_match(const mpf_codec_descript return apt_string_compare(&descriptor->name,&lpcm_attribs.name); } -/** Add default (liear PCM) capabilities */ +/** Add default (linear PCM) capabilities */ MPF_DECLARE(apt_bool_t) mpf_codec_default_capabilities_add(mpf_codec_capabilities_t *capabilities) { return mpf_codec_capabilities_add(capabilities,MPF_SAMPLE_RATE_8000,lpcm_attribs.name.buf); @@ -172,24 +171,31 @@ static mpf_codec_attribs_t* mpf_codec_capabilities_attribs_find(const mpf_codec_ return NULL; } -/** Modify codec list according to capabilities specified */ -MPF_DECLARE(apt_bool_t) mpf_codec_list_modify(mpf_codec_list_t *codec_list, const mpf_codec_capabilities_t *capabilities) +/** Match codec list with specified capabilities */ +MPF_DECLARE(apt_bool_t) mpf_codec_list_match(mpf_codec_list_t *codec_list, const mpf_codec_capabilities_t *capabilities) { int i; mpf_codec_descriptor_t *descriptor; + apt_bool_t status = FALSE; if(!capabilities) { return FALSE; } for(i=0; idescriptor_arr->nelts; i++) { descriptor = &APR_ARRAY_IDX(codec_list->descriptor_arr,i,mpf_codec_descriptor_t); + if(descriptor->enabled == FALSE) continue; + /* match capabilities */ - if(!mpf_codec_capabilities_attribs_find(capabilities,descriptor)) { + if(mpf_codec_capabilities_attribs_find(capabilities,descriptor)) { + /* at least one codec descriptor matches */ + status = TRUE; + } + else { descriptor->enabled = FALSE; } } - return TRUE; + return status; } /** Intersect two codec lists */ @@ -202,7 +208,7 @@ MPF_DECLARE(apt_bool_t) mpf_codec_lists_intersect(mpf_codec_list_t *codec_list1, codec_list1->event_descriptor = NULL; codec_list2->primary_descriptor = NULL; codec_list2->event_descriptor = NULL; - /* find only one match for primary and named event descriptors, + /* find only one match for primary and named event descriptors, set the matched descriptors as preffered, disable the others */ for(i=0; idescriptor_arr->nelts; i++) { descriptor1 = &APR_ARRAY_IDX(codec_list1->descriptor_arr,i,mpf_codec_descriptor_t); @@ -264,5 +270,10 @@ MPF_DECLARE(apt_bool_t) mpf_codec_lists_intersect(mpf_codec_list_t *codec_list1, } } + /* if primary descriptor is disabled or not set, return FALSE */ + if(!codec_list1->primary_descriptor || codec_list1->primary_descriptor->enabled == FALSE) { + return FALSE; + } + return TRUE; } diff --git a/libs/unimrcp/libs/mpf/src/mpf_codec_g711.c b/libs/unimrcp/libs/mpf/src/mpf_codec_g711.c index 5a4a66de2e..0a3bda25dc 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_codec_g711.c +++ b/libs/unimrcp/libs/mpf/src/mpf_codec_g711.c @@ -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: mpf_codec_g711.c 1686 2010-05-08 18:46:08Z achaloyan $ + * $Id: mpf_codec_g711.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_codec.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c b/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c index 7e6b091100..78a817df03 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c +++ b/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c @@ -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: mpf_codec_linear.c 1686 2010-05-08 18:46:08Z achaloyan $ + * $Id: mpf_codec_linear.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #define APR_WANT_BYTEFUNC diff --git a/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c b/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c index fa0482a610..38cd7c0e5c 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c +++ b/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c @@ -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: mpf_codec_manager.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_codec_manager.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/mpf/src/mpf_context.c b/libs/unimrcp/libs/mpf/src/mpf_context.c index bdd0034ecb..e0c35cce81 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_context.c +++ b/libs/unimrcp/libs/mpf/src/mpf_context.c @@ -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: mpf_context.c 1709 2010-05-24 17:12:11Z achaloyan $ + * $Id: mpf_context.c 2181 2014-09-14 04:29:38Z achaloyan@gmail.com $ */ #ifdef WIN32 @@ -122,6 +122,7 @@ MPF_DECLARE(mpf_context_t*) mpf_context_create( matrix_item_t *matrix_item; header_item_t *header_item; mpf_context_t *context = apr_palloc(pool,sizeof(mpf_context_t)); + APR_RING_ELEM_INIT(context,link); context->factory = factory; context->obj = obj; context->pool = pool; diff --git a/libs/unimrcp/libs/mpf/src/mpf_decoder.c b/libs/unimrcp/libs/mpf/src/mpf_decoder.c index e01d438803..f27467101f 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_decoder.c +++ b/libs/unimrcp/libs/mpf/src/mpf_decoder.c @@ -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: mpf_decoder.c 1530 2010-02-19 18:40:08Z achaloyan $ + * $Id: mpf_decoder.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_decoder.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_dtmf_detector.c b/libs/unimrcp/libs/mpf/src/mpf_dtmf_detector.c index 889416a3f2..58ca1916fd 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_dtmf_detector.c +++ b/libs/unimrcp/libs/mpf/src/mpf_dtmf_detector.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mpf_dtmf_detector.c 1788 2010-11-22 19:45:38Z tomas.valenta@speechtech.cz $ + * $Id: mpf_dtmf_detector.c 2227 2014-11-12 01:10:18Z achaloyan@gmail.com $ */ #include "mpf_dtmf_detector.h" @@ -142,8 +142,7 @@ MPF_DECLARE(char) mpf_dtmf_detector_digit_get(struct mpf_dtmf_detector_t *detect apr_thread_mutex_lock(detector->mutex); digit = detector->buf[0]; if (digit) { - /* This used to be a strcpy(), but that can give overlapping buffer issues */ - memmove(detector->buf, &detector->buf[1], strlen(&detector->buf[1]) + 1); + memmove(detector->buf, detector->buf + 1, strlen(detector->buf)); detector->digits--; } apr_thread_mutex_unlock(detector->mutex); @@ -239,7 +238,8 @@ static void goertzel_energies_digit(struct mpf_dtmf_detector_t *detector) } else if (0.25 * detector->totenergy > (reng + ceng)) { /* 16db */ /* Signal energy to total energy ratio test failed */ } else { - digit = freq2digits[rmax][cmax - DTMF_FREQUENCIES/2]; + if (cmax >= DTMF_FREQUENCIES/2 && cmax < DTMF_FREQUENCIES) + digit = freq2digits[rmax][cmax - DTMF_FREQUENCIES/2]; } /* Three successive detections will trigger the detection */ diff --git a/libs/unimrcp/libs/mpf/src/mpf_dtmf_generator.c b/libs/unimrcp/libs/mpf/src/mpf_dtmf_generator.c index ee4072e8a8..b4671adaf1 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_dtmf_generator.c +++ b/libs/unimrcp/libs/mpf/src/mpf_dtmf_generator.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mpf_dtmf_generator.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_dtmf_generator.c 2227 2014-11-12 01:10:18Z achaloyan@gmail.com $ */ #include "mpf_dtmf_generator.h" @@ -67,7 +67,7 @@ typedef struct sine_state_t { double s2; } sine_state_t; -/** Mapping event_it to frequency pair */ +/** Mapping event_id to frequency pair */ static const double dtmf_freq[DTMF_EVENT_ID_MAX+1][2] = { {941, 1336}, /* 0 */ {697, 1209}, /* 1 */ @@ -172,9 +172,9 @@ MPF_DECLARE(apt_bool_t) mpf_dtmf_generator_enqueue( qlen = strlen(generator->queue); if (qlen + dlen > MPF_DTMFGEN_QUEUE_LEN) { ret = FALSE; - apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "DTMF queue too short (%"APR_SIZE_T_FMT"), " - "cannot add %d digit%s, already has %"APR_SIZE_T_FMT, MPF_DTMFGEN_QUEUE_LEN, - dlen, dlen > 1 ? "s" : "", qlen); + apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "DTMF queue too short (%d), " + "cannot add %"APR_SIZE_T_FMT" digit%s, already has %"APR_SIZE_T_FMT, + MPF_DTMFGEN_QUEUE_LEN, dlen, dlen > 1 ? "s" : "", qlen); } else { strcpy(generator->queue + qlen, digits); ret = TRUE; @@ -209,8 +209,7 @@ MPF_DECLARE(apt_bool_t) mpf_dtmf_generator_put_frame( /* Get next valid digit from queue */ do { generator->event_id = (apr_byte_t) mpf_dtmf_char_to_event_id(*generator->queue); - /* This used to be a strcpy(), but that can give overlapping buffer issues */ - memmove(generator->queue, &generator->queue[1], strlen(&generator->queue[1]) + 1); + memmove(generator->queue, generator->queue + 1, strlen(generator->queue)); } while (*generator->queue && (generator->event_id > DTMF_EVENT_ID_MAX)); /* Reset state */ if (generator->event_id <= DTMF_EVENT_ID_MAX) { diff --git a/libs/unimrcp/libs/mpf/src/mpf_encoder.c b/libs/unimrcp/libs/mpf/src/mpf_encoder.c index c80d98fb45..cd5837725e 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_encoder.c +++ b/libs/unimrcp/libs/mpf/src/mpf_encoder.c @@ -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: mpf_encoder.c 1530 2010-02-19 18:40:08Z achaloyan $ + * $Id: mpf_encoder.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_encoder.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_engine.c b/libs/unimrcp/libs/mpf/src/mpf_engine.c index 06ef5db33f..60240cb9bb 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_engine.c +++ b/libs/unimrcp/libs/mpf/src/mpf_engine.c @@ -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: mpf_engine.c 1709 2010-05-24 17:12:11Z achaloyan $ + * $Id: mpf_engine.c 2226 2014-11-12 00:47:40Z achaloyan@gmail.com $ */ #include "mpf_engine.h" @@ -240,7 +240,7 @@ static apt_bool_t mpf_engine_start(apt_task_t *task) mpf_engine_t *engine = apt_task_object_get(task); mpf_scheduler_start(engine->scheduler); - apt_task_child_start(task); + apt_task_start_request_process(task); return TRUE; } @@ -249,7 +249,7 @@ static apt_bool_t mpf_engine_terminate(apt_task_t *task) mpf_engine_t *engine = apt_task_object_get(task); mpf_scheduler_stop(engine->scheduler); - apt_task_child_terminate(task); + apt_task_terminate_request_process(task); return TRUE; } @@ -259,12 +259,15 @@ static apt_bool_t mpf_engine_event_raise(mpf_termination_t *termination, int eve mpf_message_container_t *event_msg; mpf_message_t *mpf_message; mpf_engine_t *engine; - engine = termination->event_handler_obj; + engine = termination->media_engine; if(!engine) { return FALSE; } task_msg = apt_task_msg_get(engine->task); + if(!task_msg) { + return FALSE; + } task_msg->type = engine->task_msg_type; event_msg = (mpf_message_container_t*) task_msg->data; mpf_message = event_msg->messages; @@ -305,6 +308,9 @@ static apt_bool_t mpf_engine_msg_process(apt_task_t *task, apt_task_msg_t *msg) const mpf_message_container_t *request = (const mpf_message_container_t*) msg->data; response_msg = apt_task_msg_get(engine->task); + if(!response_msg) { + return FALSE; + } response_msg->type = engine->task_msg_type; response = (mpf_message_container_t*) response_msg->data; *response = *request; @@ -324,7 +330,7 @@ static apt_bool_t mpf_engine_msg_process(apt_task_t *task, apt_task_msg_t *msg) switch(mpf_request->command_id) { case MPF_ADD_TERMINATION: { - termination->event_handler_obj = engine; + termination->media_engine = engine; termination->event_handler = mpf_engine_event_raise; termination->codec_manager = engine->codec_manager; termination->timer_queue = engine->timer_queue; diff --git a/libs/unimrcp/libs/mpf/src/mpf_engine_factory.c b/libs/unimrcp/libs/mpf/src/mpf_engine_factory.c new file mode 100644 index 0000000000..91174dce94 --- /dev/null +++ b/libs/unimrcp/libs/mpf/src/mpf_engine_factory.c @@ -0,0 +1,78 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Id: mpf_engine_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ + */ + +#include +#include "mpf_engine_factory.h" +#include "mpf_termination_factory.h" + +/** Factory of media engines */ +struct mpf_engine_factory_t { + /** Array of pointers to media engines */ + apr_array_header_t *engines_arr; + /** Index of the current engine */ + int index; +}; + +/** Create factory of media engines. */ +MPF_DECLARE(mpf_engine_factory_t*) mpf_engine_factory_create(apr_pool_t *pool) +{ + mpf_engine_factory_t *mpf_factory = apr_palloc(pool,sizeof(mpf_engine_factory_t)); + mpf_factory->engines_arr = apr_array_make(pool,1,sizeof(mpf_engine_t*)); + mpf_factory->index = 0; + return mpf_factory; +} + +/** Add media engine to factory. */ +MPF_DECLARE(apt_bool_t) mpf_engine_factory_engine_add(mpf_engine_factory_t *mpf_factory, mpf_engine_t *media_engine) +{ + mpf_engine_t **slot; + if(!media_engine) + return FALSE; + + slot = apr_array_push(mpf_factory->engines_arr); + *slot = media_engine; + return TRUE; +} + +/** Determine whether factory is empty. */ +MPF_DECLARE(apt_bool_t) mpf_engine_factory_is_empty(const mpf_engine_factory_t *mpf_factory) +{ + return apr_is_empty_array(mpf_factory->engines_arr); +} + +/** Select next available media engine. */ +MPF_DECLARE(mpf_engine_t*) mpf_engine_factory_engine_select(mpf_engine_factory_t *mpf_factory) +{ + mpf_engine_t *media_engine = APR_ARRAY_IDX(mpf_factory->engines_arr, mpf_factory->index, mpf_engine_t*); + if(++mpf_factory->index == mpf_factory->engines_arr->nelts) { + mpf_factory->index = 0; + } + return media_engine; +} + +/** Associate media engines with RTP termination factory. */ +MPF_DECLARE(apt_bool_t) mpf_engine_factory_rtp_factory_assign(mpf_engine_factory_t *mpf_factory, mpf_termination_factory_t *rtp_factory) +{ + int i; + mpf_engine_t *media_engine; + for(i=0; iengines_arr->nelts; i++) { + media_engine = APR_ARRAY_IDX(mpf_factory->engines_arr, i, mpf_engine_t*); + mpf_termination_factory_engine_assign(rtp_factory,media_engine); + } + return TRUE; +} diff --git a/libs/unimrcp/libs/mpf/src/mpf_file_termination_factory.c b/libs/unimrcp/libs/mpf/src/mpf_file_termination_factory.c index 5da0815fe3..e6170a6aa8 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_file_termination_factory.c +++ b/libs/unimrcp/libs/mpf/src/mpf_file_termination_factory.c @@ -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: mpf_file_termination_factory.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_file_termination_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_termination.h" @@ -81,5 +81,6 @@ MPF_DECLARE(mpf_termination_factory_t*) mpf_file_termination_factory_create(apr_ { mpf_termination_factory_t *file_termination_factory = apr_palloc(pool,sizeof(mpf_termination_factory_t)); file_termination_factory->create_termination = mpf_file_termination_create; + file_termination_factory->assign_engine = NULL; return file_termination_factory; } diff --git a/libs/unimrcp/libs/mpf/src/mpf_frame_buffer.c b/libs/unimrcp/libs/mpf/src/mpf_frame_buffer.c index 6f1d568377..3669db37c2 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_frame_buffer.c +++ b/libs/unimrcp/libs/mpf/src/mpf_frame_buffer.c @@ -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: mpf_frame_buffer.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_frame_buffer.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_frame_buffer.h" @@ -29,6 +29,11 @@ struct mpf_frame_buffer_t { apr_thread_mutex_t *guard; apr_pool_t *pool; + +#ifdef MPF_FRAME_BUFFER_DEBUG + FILE *utt_in; + FILE *utt_out; +#endif }; @@ -37,6 +42,7 @@ mpf_frame_buffer_t* mpf_frame_buffer_create(apr_size_t frame_size, apr_size_t fr apr_size_t i; mpf_frame_t *frame; mpf_frame_buffer_t *buffer = apr_palloc(pool,sizeof(mpf_frame_buffer_t)); + buffer->pool = pool; buffer->frame_size = frame_size; buffer->frame_count = frame_count; @@ -51,9 +57,44 @@ mpf_frame_buffer_t* mpf_frame_buffer_create(apr_size_t frame_size, apr_size_t fr buffer->write_pos = buffer->read_pos = 0; apr_thread_mutex_create(&buffer->guard,APR_THREAD_MUTEX_UNNESTED,pool); + +#ifdef MPF_FRAME_BUFFER_DEBUG + buffer->utt_in = NULL; + buffer->utt_out = NULL; +#endif return buffer; } +#ifdef MPF_FRAME_BUFFER_DEBUG +static apr_status_t mpf_frame_buffer_file_close(void *obj) +{ + mpf_frame_buffer_t *buffer = obj; + if(buffer->utt_out) { + fclose(buffer->utt_out); + buffer->utt_out = NULL; + } + if(buffer->utt_in) { + fclose(buffer->utt_in); + buffer->utt_in = NULL; + } + return APR_SUCCESS; +} + +apt_bool_t mpf_frame_buffer_file_open(mpf_frame_buffer_t *buffer, const char *utt_file_in, const char *utt_file_out) +{ + buffer->utt_in = fopen(utt_file_in,"wb"); + if(!buffer->utt_in) + return FALSE; + + buffer->utt_out = fopen(utt_file_out,"wb"); + if(!buffer->utt_out) + return FALSE; + + apr_pool_cleanup_register(buffer->pool,buffer,mpf_frame_buffer_file_close,NULL); + return TRUE; +} +#endif + void mpf_frame_buffer_destroy(mpf_frame_buffer_t *buffer) { if(buffer->guard) { @@ -80,6 +121,12 @@ apt_bool_t mpf_frame_buffer_write(mpf_frame_buffer_t *buffer, const mpf_frame_t void *data = frame->codec_frame.buffer; apr_size_t size = frame->codec_frame.size; +#ifdef MPF_FRAME_BUFFER_DEBUG + if(buffer->utt_in) { + fwrite(data,1,size,buffer->utt_in); + } +#endif + apr_thread_mutex_lock(buffer->guard); while(buffer->write_pos - buffer->read_pos < buffer->frame_count && size >= buffer->frame_size) { write_frame = mpf_frame_buffer_frame_get(buffer,buffer->write_pos); @@ -114,6 +161,11 @@ apt_bool_t mpf_frame_buffer_read(mpf_frame_buffer_t *buffer, mpf_frame_t *media_ media_frame->codec_frame.buffer, src_media_frame->codec_frame.buffer, media_frame->codec_frame.size); +#ifdef MPF_FRAME_BUFFER_DEBUG + if(buffer->utt_out) { + fwrite(media_frame->codec_frame.buffer,1,media_frame->codec_frame.size,buffer->utt_out); + } +#endif } if(media_frame->type & MEDIA_FRAME_TYPE_EVENT) { media_frame->event_frame = src_media_frame->event_frame; diff --git a/libs/unimrcp/libs/mpf/src/mpf_jitter_buffer.c b/libs/unimrcp/libs/mpf/src/mpf_jitter_buffer.c index 5ddfb2e7be..f84521a336 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_jitter_buffer.c +++ b/libs/unimrcp/libs/mpf/src/mpf_jitter_buffer.c @@ -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,16 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mpf_jitter_buffer.c 1802 2011-05-13 02:43:12Z achaloyan $ + * $Id: mpf_jitter_buffer.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_jitter_buffer.h" +#include "mpf_trace.h" -#if ENABLE_JB_TRACE +#if ENABLE_JB_TRACE == 1 #define JB_TRACE printf +#elif ENABLE_JB_TRACE == 2 +#define JB_TRACE mpf_debug_output_trace #else -static APR_INLINE void null_trace() {} -#define JB_TRACE null_trace +#define JB_TRACE mpf_null_trace #endif struct mpf_jitter_buffer_t { @@ -38,23 +40,32 @@ struct mpf_jitter_buffer_t { /* number of frames */ apr_size_t frame_count; /* frame timestamp units (samples) */ - apr_uint32_t frame_ts; + apr_uint32_t frame_ts; /* frame size in bytes */ apr_size_t frame_size; /* playout delay in timetsamp units */ apr_uint32_t playout_delay_ts; + /* max playout delay in timetsamp units */ + apr_uint32_t max_playout_delay_ts; /* write should be synchronized (offset calculated) */ apr_byte_t write_sync; /* write timestamp offset */ - int write_ts_offset; + apr_int32_t write_ts_offset; /* write pointer in timestamp units */ apr_uint32_t write_ts; /* read pointer in timestamp units */ apr_uint32_t read_ts; + /* min length of the buffer in timestamp units */ + apr_int32_t min_length_ts; + /* max length of the buffer in timestamp units */ + apr_int32_t max_length_ts; + /* number of statistical measurements made */ + apr_uint32_t measurment_count; + /* timestamp event starts at */ apr_uint32_t event_write_base_ts; /* the first (base) frame of the event */ @@ -75,23 +86,20 @@ mpf_jitter_buffer_t* mpf_jitter_buffer_create(mpf_jb_config_t *jb_config, mpf_co mpf_jb_config_init(jb_config); } /* validate jb config */ - if(jb_config->initial_playout_delay == 0) { - /* default configuration */ - jb_config->min_playout_delay = 10; /* ms */ - jb_config->initial_playout_delay = 50; /* ms */ - jb_config->max_playout_delay = 200; /* ms */ + if(jb_config->min_playout_delay > jb_config->initial_playout_delay) { + jb_config->min_playout_delay = jb_config->initial_playout_delay; } - else { - if(jb_config->min_playout_delay > jb_config->initial_playout_delay) { - jb_config->min_playout_delay = jb_config->initial_playout_delay; - } - if(jb_config->max_playout_delay < jb_config->initial_playout_delay) { - jb_config->max_playout_delay = 2 * jb_config->initial_playout_delay; - } + if(jb_config->max_playout_delay < jb_config->initial_playout_delay) { + jb_config->max_playout_delay = 2 * jb_config->initial_playout_delay; } + if(jb_config->max_playout_delay == 0) { + jb_config->max_playout_delay = 600; /* ms */ + } + jb->config = jb_config; jb->codec = codec; + /* calculate and allocate frame related data */ jb->frame_ts = (apr_uint32_t)mpf_codec_frame_samples_calculate(descriptor); jb->frame_size = mpf_codec_frame_size_calculate(descriptor,codec->attribs); jb->frame_count = jb->config->max_playout_delay / CODEC_FRAME_TIME_BASE; @@ -108,13 +116,17 @@ mpf_jitter_buffer_t* mpf_jitter_buffer_create(mpf_jb_config_t *jb_config, mpf_co jb->config->initial_playout_delay += CODEC_FRAME_TIME_BASE - jb->config->initial_playout_delay % CODEC_FRAME_TIME_BASE; } - jb->playout_delay_ts = (apr_uint32_t)(jb->config->initial_playout_delay * - descriptor->channel_count * descriptor->sampling_rate / 1000); + /* calculate playout delay in timestamp units */ + jb->playout_delay_ts = jb->frame_ts * jb->config->initial_playout_delay / CODEC_FRAME_TIME_BASE; + jb->max_playout_delay_ts = jb->frame_ts * jb->config->max_playout_delay / CODEC_FRAME_TIME_BASE; jb->write_sync = 1; jb->write_ts_offset = 0; jb->write_ts = jb->read_ts = 0; + jb->min_length_ts = jb->max_length_ts = 0; + jb->measurment_count = 0; + jb->event_write_base_ts = 0; memset(&jb->event_write_base,0,sizeof(mpf_named_event_frame_t)); jb->event_write_update = NULL; @@ -136,6 +148,11 @@ apt_bool_t mpf_jitter_buffer_restart(mpf_jitter_buffer_t *jb) memset(&jb->event_write_base,0,sizeof(mpf_named_event_frame_t)); jb->event_write_update = NULL; + if(jb->config->adaptive && jb->playout_delay_ts == jb->max_playout_delay_ts) { + jb->playout_delay_ts = jb->frame_ts * jb->config->initial_playout_delay / CODEC_FRAME_TIME_BASE; + } + + JB_TRACE("JB restart\n"); return TRUE; } @@ -145,18 +162,61 @@ static APR_INLINE mpf_frame_t* mpf_jitter_buffer_frame_get(mpf_jitter_buffer_t * return &jb->frames[index]; } +static APR_INLINE void mpf_jitter_buffer_stat_update(mpf_jitter_buffer_t *jb) +{ + apr_int32_t length_ts; + + if(jb->measurment_count == 50) { + /* start over after every N measurements */ + apr_int32_t mean_length_ts = jb->min_length_ts + (jb->max_length_ts - jb->min_length_ts) / 2; + JB_TRACE("JB stat length [%d : %d] playout delay=%u\n", + jb->min_length_ts,jb->max_length_ts,jb->playout_delay_ts); + jb->min_length_ts = jb->max_length_ts = mean_length_ts; + jb->measurment_count = 0; + } + + /* calculate current length of the buffer */ + length_ts = jb->write_ts - jb->read_ts; + if(length_ts > jb->max_length_ts) { + /* update max length */ + jb->max_length_ts = length_ts; + } + else if(length_ts < jb->min_length_ts) { + /* update min length */ + jb->min_length_ts = length_ts; + } + /* increment the counter after every stat update */ + jb->measurment_count++; +} + +static APR_INLINE void mpf_jitter_buffer_frame_allign(mpf_jitter_buffer_t *jb, apr_uint32_t *ts) +{ + if(*ts % jb->frame_ts != 0) + *ts -= *ts % jb->frame_ts; +} + static APR_INLINE jb_result_t mpf_jitter_buffer_write_prepare(mpf_jitter_buffer_t *jb, apr_uint32_t ts, apr_uint32_t *write_ts) { if(jb->write_sync) { - jb->write_ts_offset = ts - jb->write_ts; + JB_TRACE("JB write sync playout delay=%u\n",jb->playout_delay_ts); + /* calculate the offset */ + jb->write_ts_offset = ts - jb->read_ts; jb->write_sync = 0; + + if(jb->config->time_skew_detection) { + /* reset the statistics */ + jb->min_length_ts = jb->max_length_ts = jb->playout_delay_ts; + jb->measurment_count = 0; + } } + /* calculate the write pos taking into account current offset and playout delay */ *write_ts = ts - jb->write_ts_offset + jb->playout_delay_ts; if(*write_ts % jb->frame_ts != 0) { - /* not frame alligned */ - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" not alligned -> discard\n",write_ts); - return JB_DISCARD_NOT_ALLIGNED; + /* allign with frame_ts */ + apr_uint32_t delta_ts = *write_ts % jb->frame_ts; + JB_TRACE("JB write allign ts=%u delta_ts=-%u\n",*write_ts,delta_ts); + *write_ts -= delta_ts; } return JB_OK; } @@ -169,42 +229,109 @@ jb_result_t mpf_jitter_buffer_write(mpf_jitter_buffer_t *jb, void *buffer, apr_s jb_result_t result; if(marker) { - /* new talkspurt */ + JB_TRACE("JB marker\n"); + /* new talkspurt detected => test whether the buffer is empty */ if(jb->write_ts <= jb->read_ts) { - /* buffer is empty => it's safe to restart */ - mpf_jitter_buffer_restart(jb); + /* resync */ + jb->write_sync = 1; } } + /* calculate write_ts */ result = mpf_jitter_buffer_write_prepare(jb,ts,&write_ts); if(result != JB_OK) { return result; } - if(write_ts >= jb->write_ts) { - if(write_ts - jb->write_ts > jb->frame_ts) { - /* gap */ - } - /* normal write */ - } - else { - if(write_ts >= jb->read_ts) { - /* backward write */ + if(write_ts >= jb->read_ts) { + if(write_ts >= jb->write_ts) { + /* normal order */ } else { - /* too late */ - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" too late\n",write_ts); - return JB_DISCARD_TOO_LATE; + /* out of order */ } } + else { + apr_uint32_t delta_ts; + /* packet arrived too late */ + if(write_ts < jb->write_ts) { + /* out of order => discard */ + JB_TRACE("JB write ts=%u out of order, too late => discard\n",write_ts); + return JB_DISCARD_TOO_LATE; + } + + /* calculate a minimal adjustment needed in order to place the packet into the buffer */ + delta_ts = jb->read_ts - write_ts; + + if(jb->config->time_skew_detection) { + JB_TRACE("JB stat length [%d : %d] playout delay=%u delta=%u\n", + jb->min_length_ts,jb->max_length_ts,jb->playout_delay_ts,delta_ts); + + if((apr_uint32_t)(jb->max_length_ts - jb->min_length_ts) > jb->playout_delay_ts + delta_ts) { + /* update the adjustment based on the collected statistics */ + delta_ts = (apr_uint32_t)(jb->max_length_ts - jb->min_length_ts) - jb->playout_delay_ts; + mpf_jitter_buffer_frame_allign(jb,&delta_ts); + } + + /* determine if there might be a time skew or not */ + if(jb->max_length_ts > 0 && (apr_uint32_t)jb->max_length_ts < jb->playout_delay_ts) { + /* calculate the time skew */ + apr_uint32_t skew_ts = jb->playout_delay_ts - jb->max_length_ts; + mpf_jitter_buffer_frame_allign(jb,&skew_ts); + JB_TRACE("JB time skew detected offset=%u\n",skew_ts); + + /* adjust the offset and write pos */ + jb->write_ts_offset -= skew_ts; + write_ts = ts - jb->write_ts_offset + jb->playout_delay_ts; + + /* adjust the statistics */ + jb->min_length_ts += skew_ts; + jb->max_length_ts += skew_ts; + + if(skew_ts < delta_ts) { + delta_ts -= skew_ts; + } + else { + delta_ts = 0; + } + } + } + + if(delta_ts) { + if(jb->config->adaptive == 0) { + /* jitter buffer is not adaptive => discard the packet */ + JB_TRACE("JB write ts=%u too late => discard\n",write_ts); + return JB_DISCARD_TOO_LATE; + } + + if(jb->playout_delay_ts + delta_ts > jb->max_playout_delay_ts) { + /* max playout delay will be reached => discard the packet */ + JB_TRACE("JB write ts=%u max playout delay reached => discard\n",write_ts); + return JB_DISCARD_TOO_LATE; + } + + /* adjust the playout delay */ + jb->playout_delay_ts += delta_ts; + write_ts += delta_ts; + JB_TRACE("JB adjust playout delay=%u delta=%u\n",jb->playout_delay_ts,delta_ts); + + if(jb->config->time_skew_detection) { + /* adjust the statistics */ + jb->min_length_ts += delta_ts; + jb->max_length_ts += delta_ts; + } + } + } + + /* get number of frames available to write */ available_frame_count = jb->frame_count - (write_ts - jb->read_ts)/jb->frame_ts; if(available_frame_count <= 0) { /* too early */ - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" too early\n",write_ts); + JB_TRACE("JB write ts=%u too early => discard\n",write_ts); return JB_DISCARD_TOO_EARLY; } - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" size=%"APR_SIZE_T_FMT"\n",write_ts,size); + JB_TRACE("JB write ts=%u size=%"APR_SIZE_T_FMT"\n",write_ts,size); while(available_frame_count && size) { media_frame = mpf_jitter_buffer_frame_get(jb,write_ts); media_frame->codec_frame.size = jb->frame_size; @@ -222,6 +349,7 @@ jb_result_t mpf_jitter_buffer_write(mpf_jitter_buffer_t *jb, void *buffer, apr_s } if(write_ts > jb->write_ts) { + /* advance write pos */ jb->write_ts = write_ts; } return result; @@ -265,30 +393,58 @@ jb_result_t mpf_jitter_buffer_event_write(mpf_jitter_buffer_t *jb, const mpf_nam } else { /* an update */ - if(named_event->duration <= jb->event_write_update->duration) { - /* ignore this update, it's either a retransmission or - something from the past, which makes no sense now */ + if(named_event->duration < jb->event_write_update->duration) { + /* ignore this update, it's something from the past, which makes no sense now */ return JB_OK; } + else if(named_event->duration == jb->event_write_update->duration) { + /* this should be a retransmission, let it go through only if it contains new data */ + if(jb->event_write_update->edge == 1 || jb->event_write_update->edge == named_event->edge) { + /* ignore this update since either the end of event marker has already been set, + or the current event provides no updates */ + return JB_OK; + } + } + /* calculate position in jitter buffer considering the last received event (update) */ write_ts += jb->event_write_update->duration; } if(write_ts < jb->read_ts) { /* too late */ - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" event=%d duration=%d too late\n", - write_ts,named_event->event_id,named_event->duration); - return JB_DISCARD_TOO_LATE; + apr_uint32_t delta_ts; + if(jb->config->adaptive == 0) { + /* jitter buffer is not adaptive => discard the packet */ + JB_TRACE("JB write ts=%u event=%d duration=%d too late => discard\n", + write_ts,named_event->event_id,named_event->duration); + return JB_DISCARD_TOO_LATE; + } + + /* calculate a minimal adjustment needed in order to place the packet into the buffer */ + delta_ts = jb->read_ts - write_ts; + + if(jb->playout_delay_ts + delta_ts > jb->max_playout_delay_ts) { + /* max playout delay will be reached => discard the packet */ + JB_TRACE("JB write ts=%u event=%d duration=%d max playout delay reached => discard\n", + write_ts,named_event->event_id,named_event->duration); + return JB_DISCARD_TOO_LATE; + } + + /* adjust the playout delay */ + jb->playout_delay_ts += delta_ts; + write_ts += delta_ts; + if(marker) { + jb->event_write_base_ts = write_ts; + } + JB_TRACE("JB adjust playout delay=%u delta=%u\n",jb->playout_delay_ts,delta_ts); } else if( (write_ts - jb->read_ts)/jb->frame_ts >= jb->frame_count) { /* too early */ - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" event=%d duration=%d too early\n", + JB_TRACE("JB write ts=%u event=%d duration=%d too early => discard\n", write_ts,named_event->event_id,named_event->duration); return JB_DISCARD_TOO_EARLY; } - JB_TRACE("JB write ts=%"APR_SIZE_T_FMT" event=%d duration=%d\n", - write_ts,named_event->event_id,named_event->duration); media_frame = mpf_jitter_buffer_frame_get(jb,write_ts); media_frame->event_frame = *named_event; media_frame->type |= MEDIA_FRAME_TYPE_EVENT; @@ -298,10 +454,13 @@ jb_result_t mpf_jitter_buffer_event_write(mpf_jitter_buffer_t *jb, const mpf_nam else if(named_event->edge == 1) { media_frame->marker = MPF_MARKER_END_OF_EVENT; } + JB_TRACE("JB write ts=%u event=%d duration=%d marker=%d\n", + write_ts,named_event->event_id,named_event->duration,media_frame->marker); jb->event_write_update = &media_frame->event_frame; write_ts += jb->frame_ts; if(write_ts > jb->write_ts) { + /* advance write pos */ jb->write_ts = write_ts; } return result; @@ -312,7 +471,7 @@ apt_bool_t mpf_jitter_buffer_read(mpf_jitter_buffer_t *jb, mpf_frame_t *media_fr mpf_frame_t *src_media_frame = mpf_jitter_buffer_frame_get(jb,jb->read_ts); if(jb->write_ts > jb->read_ts) { /* normal read */ - JB_TRACE("JB read ts=%"APR_SIZE_T_FMT"\n", jb->read_ts); + JB_TRACE("JB read ts=%u\n", jb->read_ts); media_frame->type = src_media_frame->type; media_frame->marker = src_media_frame->marker; if(media_frame->type & MEDIA_FRAME_TYPE_AUDIO) { @@ -325,13 +484,27 @@ apt_bool_t mpf_jitter_buffer_read(mpf_jitter_buffer_t *jb, mpf_frame_t *media_fr } else { /* underflow */ - JB_TRACE("JB read ts=%"APR_SIZE_T_FMT" underflow\n", jb->read_ts); + JB_TRACE("JB read ts=%u underflow\n", jb->read_ts); media_frame->type = MEDIA_FRAME_TYPE_NONE; media_frame->marker = MPF_MARKER_NONE; - jb->write_ts += jb->frame_ts; } src_media_frame->type = MEDIA_FRAME_TYPE_NONE; src_media_frame->marker = MPF_MARKER_NONE; + /* advance read pos */ jb->read_ts += jb->frame_ts; + + if(jb->config->time_skew_detection) { + /* update statistics after every read */ + mpf_jitter_buffer_stat_update(jb); + } return TRUE; } + +apr_uint32_t mpf_jitter_buffer_playout_delay_get(const mpf_jitter_buffer_t *jb) +{ + if(jb->config->adaptive == 0) { + return jb->config->initial_playout_delay; + } + + return jb->playout_delay_ts * CODEC_FRAME_TIME_BASE / jb->frame_ts; +} diff --git a/libs/unimrcp/libs/mpf/src/mpf_mixer.c b/libs/unimrcp/libs/mpf/src/mpf_mixer.c index 3c36dd449d..d4c5b3029d 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_mixer.c +++ b/libs/unimrcp/libs/mpf/src/mpf_mixer.c @@ -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: mpf_mixer.c 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_mixer.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_mixer.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_multiplier.c b/libs/unimrcp/libs/mpf/src/mpf_multiplier.c index 2014932841..153c6cda9b 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_multiplier.c +++ b/libs/unimrcp/libs/mpf/src/mpf_multiplier.c @@ -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: mpf_multiplier.c 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_multiplier.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_multiplier.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_named_event.c b/libs/unimrcp/libs/mpf/src/mpf_named_event.c index 22c319dae4..22df9b07c2 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_named_event.c +++ b/libs/unimrcp/libs/mpf/src/mpf_named_event.c @@ -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: mpf_named_event.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_named_event.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_named_event.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_resampler.c b/libs/unimrcp/libs/mpf/src/mpf_resampler.c index fe4a45c9fc..bcd802245f 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_resampler.c +++ b/libs/unimrcp/libs/mpf/src/mpf_resampler.c @@ -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: mpf_resampler.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_resampler.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_resampler.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_rtp_attribs.c b/libs/unimrcp/libs/mpf/src/mpf_rtp_attribs.c index 5e9e184f0f..f6f84174e2 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_rtp_attribs.c +++ b/libs/unimrcp/libs/mpf/src/mpf_rtp_attribs.c @@ -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: mpf_rtp_attribs.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_rtp_attribs.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_string_table.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_rtp_stream.c b/libs/unimrcp/libs/mpf/src/mpf_rtp_stream.c index f94b3295c2..9f47521489 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_rtp_stream.c +++ b/libs/unimrcp/libs/mpf/src/mpf_rtp_stream.c @@ -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: mpf_rtp_stream.c 1802 2011-05-13 02:43:12Z achaloyan $ + * $Id: mpf_rtp_stream.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -26,6 +26,7 @@ #include "mpf_rtcp_packet.h" #include "mpf_rtp_defs.h" #include "mpf_rtp_pt.h" +#include "mpf_trace.h" #include "apt_log.h" /** Max size of RTP packet */ @@ -37,11 +38,12 @@ #define RTCP_BYE_SESSION_ENDED "Session ended" #define RTCP_BYE_TALKSPURT_ENDED "Talskpurt ended" -#if ENABLE_RTP_PACKET_TRACE +#if ENABLE_RTP_PACKET_TRACE == 1 #define RTP_TRACE printf +#elif ENABLE_RTP_PACKET_TRACE == 2 +#define RTP_TRACE mpf_debug_output_trace #else -static APR_INLINE void null_trace() {} -#define RTP_TRACE null_trace +#define RTP_TRACE mpf_null_trace #endif /** RTP stream */ @@ -87,10 +89,12 @@ static const mpf_audio_stream_vtable_t vtable = { mpf_rtp_stream_receive, mpf_rtp_tx_stream_open, mpf_rtp_tx_stream_close, - mpf_rtp_stream_transmit + mpf_rtp_stream_transmit, + NULL /* mpf_rtp_stream_trace */ }; -static apt_bool_t mpf_rtp_socket_pair_create(mpf_rtp_stream_t *stream, mpf_rtp_media_descriptor_t *local_media); +static apt_bool_t mpf_rtp_socket_pair_create(mpf_rtp_stream_t *stream, mpf_rtp_media_descriptor_t *local_media, apt_bool_t bind); +static apt_bool_t mpf_rtp_socket_pair_bind(mpf_rtp_stream_t *stream, mpf_rtp_media_descriptor_t *local_media); static void mpf_rtp_socket_pair_close(mpf_rtp_stream_t *stream); static apt_bool_t mpf_rtcp_report_send(mpf_rtp_stream_t *stream); @@ -166,35 +170,45 @@ static apt_bool_t mpf_rtp_stream_local_media_create(mpf_rtp_stream_t *rtp_stream local_media->ext_ip = rtp_stream->config->ext_ip; } if(local_media->port == 0) { - /* RTP port management */ - mpf_rtp_config_t *rtp_config = rtp_stream->config; - apr_port_t first_port_in_search = rtp_config->rtp_port_cur; - apt_bool_t is_port_ok = FALSE; + if(mpf_rtp_socket_pair_create(rtp_stream,local_media,FALSE) == TRUE) { + /* RTP port management */ + mpf_rtp_config_t *rtp_config = rtp_stream->config; + apr_port_t first_port_in_search = rtp_config->rtp_port_cur; + apt_bool_t is_port_ok = FALSE; + do { + local_media->port = rtp_config->rtp_port_cur; + rtp_config->rtp_port_cur += 2; + if(rtp_config->rtp_port_cur == rtp_config->rtp_port_max) { + rtp_config->rtp_port_cur = rtp_config->rtp_port_min; + } + + if(mpf_rtp_socket_pair_bind(rtp_stream,local_media) == TRUE) { + is_port_ok = TRUE; + break; + } + } while(first_port_in_search != rtp_config->rtp_port_cur); - do { - local_media->port = rtp_config->rtp_port_cur; - rtp_config->rtp_port_cur += 2; - if(rtp_config->rtp_port_cur == rtp_config->rtp_port_max) { - rtp_config->rtp_port_cur = rtp_config->rtp_port_min; + if(is_port_ok == FALSE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Find Free RTP Port %s:[%hu,%hu]", + rtp_config->ip.buf, + rtp_config->rtp_port_min, + rtp_config->rtp_port_max); + mpf_rtp_socket_pair_close(rtp_stream); + status = FALSE; } - if(mpf_rtp_socket_pair_create(rtp_stream,local_media) == TRUE) { - is_port_ok = TRUE; - } - } while((is_port_ok == FALSE) && (first_port_in_search != rtp_config->rtp_port_cur)); - if(is_port_ok == FALSE) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Find Free RTP Port %s:[%hu,%hu]", - rtp_config->ip.buf, - rtp_config->rtp_port_min, - rtp_config->rtp_port_max); - local_media->state = MPF_MEDIA_DISABLED; + } + else { status = FALSE; } } - else if(mpf_rtp_socket_pair_create(rtp_stream,local_media) == FALSE) { - local_media->state = MPF_MEDIA_DISABLED; + else if(mpf_rtp_socket_pair_create(rtp_stream,local_media,TRUE) == FALSE) { status = FALSE; } + if(status == FALSE) { + local_media->state = MPF_MEDIA_DISABLED; + } + if(rtp_stream->settings->ptime) { local_media->ptime = rtp_stream->settings->ptime; } @@ -211,9 +225,15 @@ static apt_bool_t mpf_rtp_stream_local_media_create(mpf_rtp_stream_t *rtp_stream &rtp_stream->settings->codec_list, rtp_stream->pool); } - - if(capabilities) { - mpf_codec_list_modify(&local_media->codec_list,&capabilities->codecs); + } + + if(capabilities) { + if(mpf_codec_list_match(&local_media->codec_list,&capabilities->codecs) == FALSE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Match Codec List %s:%hu", + local_media->ip.buf, + local_media->port); + local_media->state = MPF_MEDIA_DISABLED; + status = FALSE; } } @@ -227,7 +247,9 @@ static apt_bool_t mpf_rtp_stream_local_media_update(mpf_rtp_stream_t *rtp_stream if(apt_string_compare(&rtp_stream->local_media->ip,&media->ip) == FALSE || rtp_stream->local_media->port != media->port) { - if(mpf_rtp_socket_pair_create(rtp_stream,media) == FALSE) { + mpf_rtp_socket_pair_close(rtp_stream); + + if(mpf_rtp_socket_pair_create(rtp_stream,media,TRUE) == FALSE) { media->state = MPF_MEDIA_DISABLED; status = FALSE; } @@ -237,8 +259,15 @@ static apt_bool_t mpf_rtp_stream_local_media_update(mpf_rtp_stream_t *rtp_stream rtp_stream->base->termination->codec_manager, &media->codec_list, rtp_stream->pool); - if(capabilities) { - mpf_codec_list_modify(&media->codec_list,&capabilities->codecs); + } + + if(capabilities) { + if(mpf_codec_list_match(&media->codec_list,&capabilities->codecs) == FALSE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Match Codec List %s:%hu", + media->ip.buf, + media->port); + media->state = MPF_MEDIA_DISABLED; + status = FALSE; } } @@ -334,29 +363,42 @@ static apt_bool_t mpf_rtp_stream_media_negotiate(mpf_rtp_stream_t *rtp_stream) local_media->state = remote_media->state; local_media->direction = mpf_stream_reverse_direction_get(remote_media->direction); - rtp_stream->base->direction = local_media->direction; if(remote_media->state == MPF_MEDIA_ENABLED) { - if(mpf_codec_list_is_empty(&remote_media->codec_list) == TRUE) { - /* no remote codecs available, initialize them according to the local codecs */ - mpf_codec_list_copy(&remote_media->codec_list, - &local_media->codec_list, - rtp_stream->pool); - } + mpf_codec_list_t *codec_list1 = NULL; + mpf_codec_list_t *codec_list2 = NULL; /* intersect local and remote codecs */ if(rtp_stream->settings->own_preferrence == TRUE) { - mpf_codec_lists_intersect( - &local_media->codec_list, - &remote_media->codec_list); + codec_list1 = &local_media->codec_list; + codec_list2 = &remote_media->codec_list; } else { - mpf_codec_lists_intersect( - &remote_media->codec_list, - &local_media->codec_list); + codec_list2 = &local_media->codec_list; + codec_list1 = &remote_media->codec_list; + } + + if(mpf_codec_lists_intersect(codec_list1,codec_list2) == FALSE) { + /* reject RTP/RTCP session */ + rtp_stream->state = MPF_MEDIA_DISABLED; + local_media->direction = STREAM_DIRECTION_NONE; + local_media->state = MPF_MEDIA_DISABLED; + if(rtp_stream->rtp_l_sockaddr) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Reject RTP Session %s:%hu no codecs matched", + rtp_stream->rtp_l_sockaddr->hostname, + rtp_stream->rtp_l_sockaddr->port); + } + + if(rtp_stream->rtcp_tx_timer) { + apt_timer_kill(rtp_stream->rtcp_tx_timer); + } + if(rtp_stream->rtcp_rx_timer) { + apt_timer_kill(rtp_stream->rtcp_rx_timer); + } } } + rtp_stream->base->direction = local_media->direction; return TRUE; } @@ -444,7 +486,6 @@ MPF_DECLARE(apt_bool_t) mpf_rtp_stream_modify(mpf_audio_stream_t *stream, mpf_rt return status; } - static apt_bool_t mpf_rtp_stream_destroy(mpf_audio_stream_t *stream) { return TRUE; @@ -454,22 +495,28 @@ static apt_bool_t mpf_rtp_rx_stream_open(mpf_audio_stream_t *stream, mpf_codec_t { mpf_rtp_stream_t *rtp_stream = stream->obj; rtp_receiver_t *receiver = &rtp_stream->receiver; + mpf_jb_config_t *jb_config = &rtp_stream->settings->jb_config; if(!rtp_stream->rtp_socket || !rtp_stream->rtp_l_sockaddr || !rtp_stream->rtp_r_sockaddr) { return FALSE; } receiver->jb = mpf_jitter_buffer_create( - &rtp_stream->settings->jb_config, + jb_config, stream->rx_descriptor, codec, rtp_stream->pool); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open RTP Receiver %s:%hu <- %s:%hu playout [%"APR_SIZE_T_FMT" ms]", + apt_log(APT_LOG_MARK,APT_PRIO_INFO, + "Open RTP Receiver %s:%hu <- %s:%hu playout [%u ms] bounds [%u - %u ms] adaptive [%d] skew detection [%d]", rtp_stream->rtp_l_sockaddr->hostname, rtp_stream->rtp_l_sockaddr->port, rtp_stream->rtp_r_sockaddr->hostname, rtp_stream->rtp_r_sockaddr->port, - rtp_stream->settings->jb_config.initial_playout_delay); + jb_config->initial_playout_delay, + jb_config->min_playout_delay, + jb_config->max_playout_delay, + jb_config->adaptive, + jb_config->time_skew_detection); return TRUE; } @@ -491,8 +538,7 @@ static apt_bool_t mpf_rtp_rx_stream_close(mpf_audio_stream_t *stream) } } - mpf_jitter_buffer_destroy(receiver->jb); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close RTP Receiver %s:%hu <- %s:%hu [r:%u l:%u j:%u d:%u i:%u]", + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close RTP Receiver %s:%hu <- %s:%hu [r:%u l:%u j:%u p:%u d:%u i:%u]", rtp_stream->rtp_l_sockaddr->hostname, rtp_stream->rtp_l_sockaddr->port, rtp_stream->rtp_r_sockaddr->hostname, @@ -500,8 +546,10 @@ static apt_bool_t mpf_rtp_rx_stream_close(mpf_audio_stream_t *stream) receiver->stat.received_packets, receiver->stat.lost_packets, receiver->rr_stat.jitter, + mpf_jitter_buffer_playout_delay_get(receiver->jb), receiver->stat.discarded_packets, receiver->stat.ignored_packets); + mpf_jitter_buffer_destroy(receiver->jb); return TRUE; } @@ -684,13 +732,24 @@ typedef enum { RTP_TS_DRIFT } rtp_ts_result_e; -static APR_INLINE rtp_ts_result_e rtp_rx_ts_update(rtp_receiver_t *receiver, mpf_codec_descriptor_t *descriptor, apr_time_t *time, apr_uint32_t ts) +static APR_INLINE rtp_ts_result_e rtp_rx_ts_update(rtp_receiver_t *receiver, mpf_codec_descriptor_t *descriptor, apr_time_t *time, apr_uint32_t ts, apr_byte_t *marker) { apr_int32_t deviation; + apr_int32_t time_diff; + + /* arrival time diff in msec */ + time_diff = (apr_int32_t)apr_time_as_msec(*time - receiver->history.time_last); + + /* if the time difference is more than the threshold (INTER_TALKSPURT_GAP), + and the marker is not set, then this might be a beginning of a + new malformed talkspurt */ + if(!*marker && time_diff > INTER_TALKSPURT_GAP) { + /* set the missing marker */ + *marker = 1; + } /* arrival time diff in samples */ - deviation = (apr_int32_t)apr_time_as_msec(*time - receiver->history.time_last) * - descriptor->channel_count * descriptor->sampling_rate / 1000; + deviation = time_diff * descriptor->channel_count * descriptor->sampling_rate / 1000; /* arrival timestamp diff */ deviation -= ts - receiver->history.ts_last; @@ -703,7 +762,7 @@ static APR_INLINE rtp_ts_result_e rtp_rx_ts_update(rtp_receiver_t *receiver, mpf } receiver->rr_stat.jitter += deviation - ((receiver->rr_stat.jitter + 8) >> 4); - RTP_TRACE("jitter=%d deviation=%d\n",receiver->rr_stat.jitter,deviation); + RTP_TRACE("jitter=%u deviation=%d\n",receiver->rr_stat.jitter,deviation); receiver->history.time_last = *time; receiver->history.ts_last = ts; @@ -771,12 +830,13 @@ static apt_bool_t rtp_rx_packet_receive(mpf_rtp_stream_t *rtp_stream, void *buff if(header->type == descriptor->payload_type) { /* codec */ - if(rtp_rx_ts_update(receiver,descriptor,&time,header->timestamp) == RTP_TS_DRIFT) { + apr_byte_t marker = (apr_byte_t)header->marker; + if(rtp_rx_ts_update(receiver,descriptor,&time,header->timestamp,&marker) == RTP_TS_DRIFT) { rtp_rx_restart(receiver); return FALSE; } - if(mpf_jitter_buffer_write(receiver->jb,buffer,size,header->timestamp,(apr_byte_t)header->marker) != JB_OK) { + if(mpf_jitter_buffer_write(receiver->jb,buffer,size,header->timestamp,marker) != JB_OK) { receiver->stat.discarded_packets++; rtp_rx_failure_threshold_check(receiver); } @@ -912,7 +972,7 @@ static APR_INLINE apt_bool_t mpf_rtp_data_send(mpf_rtp_stream_t *rtp_stream, rtp if(++transmitter->current_frames == transmitter->packet_frames) { rtp_header_t *header = (rtp_header_t*)transmitter->packet_data; header->sequence = htons(++transmitter->last_seq_num); - RTP_TRACE("> RTP time=%6lu ssrc=%8lx pt=%3u %cts=%9lu seq=%5u\n", + RTP_TRACE("> RTP time=%6u ssrc=%8x pt=%3u %cts=%9u seq=%5hu\n", (apr_uint32_t)apr_time_usec(apr_time_now()), transmitter->sr_stat.ssrc, header->type, (header->marker == 1) ? '*' : ' ', @@ -952,14 +1012,13 @@ static APR_INLINE apt_bool_t mpf_rtp_event_send(mpf_rtp_stream_t *rtp_stream, rt named_event->edge = (frame->marker == MPF_MARKER_END_OF_EVENT) ? 1 : 0; header->sequence = htons(++transmitter->last_seq_num); - RTP_TRACE("> RTP time=%6lu ssrc=%8lx pt=%3u %cts=%9lu seq=%5u event=%2u dur=%3u %c\n", + RTP_TRACE("> RTP time=%6u ssrc=%8x pt=%3u %cts=%9u seq=%hu event=%2u dur=%3u %c\n", (apr_uint32_t)apr_time_usec(apr_time_now()), transmitter->sr_stat.ssrc, header->type, (header->marker == 1) ? '*' : ' ', header->timestamp, transmitter->last_seq_num, named_event->event_id, named_event->duration, (named_event->edge == 1) ? '*' : ' '); - header->timestamp = htonl(header->timestamp); named_event->duration = htons((apr_uint16_t)named_event->duration); if(apr_socket_sendto( @@ -1037,9 +1096,27 @@ static apt_bool_t mpf_rtp_stream_transmit(mpf_audio_stream_t *stream, const mpf_ return status; } -static apr_socket_t* mpf_socket_create(apr_sockaddr_t **l_sockaddr, const char *ip, apr_port_t port, apr_pool_t *pool) +static apt_bool_t mpf_socket_create(apr_pool_t *pool, apr_socket_t **socket) { - apr_socket_t *socket = NULL; + if(!socket) + return FALSE; + + if(apr_socket_create(socket,APR_INET,SOCK_DGRAM,0,pool) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Socket"); + *socket = NULL; + return FALSE; + } + + apr_socket_opt_set(*socket,APR_SO_NONBLOCK,1); + apr_socket_timeout_set(*socket,0); + return TRUE; +} + +static apt_bool_t mpf_socket_bind(apr_socket_t *socket, const char *ip, apr_port_t port, apr_pool_t *pool, apr_sockaddr_t **l_sockaddr) +{ + if(!socket || !l_sockaddr) + return FALSE; + *l_sockaddr = NULL; apr_sockaddr_info_get( l_sockaddr, @@ -1049,41 +1126,56 @@ static apr_socket_t* mpf_socket_create(apr_sockaddr_t **l_sockaddr, const char * 0, pool); if(!*l_sockaddr) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Failed to Get Sockaddr %s:%hu",ip,port); - return NULL; - } - if(apr_socket_create(&socket,(*l_sockaddr)->family,SOCK_DGRAM,0,pool) != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Failed to Create Socket %s:%hu", ip,port); - return NULL; - } - - apr_socket_opt_set(socket,APR_SO_NONBLOCK,1); - apr_socket_timeout_set(socket,0); - apr_socket_opt_set(socket,APR_SO_REUSEADDR,1); - - if(apr_socket_bind(socket,*l_sockaddr) != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Failed to Bind Socket to %s:%hu", ip,port); - apr_socket_close(socket); - return NULL; - } - return socket; -} - -static apt_bool_t mpf_rtp_socket_pair_create(mpf_rtp_stream_t *stream, mpf_rtp_media_descriptor_t *local_media) -{ - stream->rtp_socket = mpf_socket_create(&stream->rtp_l_sockaddr,local_media->ip.buf,local_media->port,stream->pool); - if(!stream->rtp_socket) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Failed to Create RTP Socket"); + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Sockaddr %s:%hu",ip,port); return FALSE; } - - stream->rtcp_socket = mpf_socket_create(&stream->rtcp_l_sockaddr,local_media->ip.buf,local_media->port+1,stream->pool); - if(!stream->rtcp_socket) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Failed to Create RTCP Socket"); + + if(apr_socket_bind(socket,*l_sockaddr) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Failed to Bind Socket to %s:%hu", ip,port); + return FALSE; } return TRUE; } +/* Create RTP/RTCP sockets */ +static apt_bool_t mpf_rtp_socket_pair_create(mpf_rtp_stream_t *stream, mpf_rtp_media_descriptor_t *local_media, apt_bool_t bind) +{ + /* Create and optionally bind RTP socket. Return FALSE in case of an error. */ + if(mpf_socket_create(stream->pool,&stream->rtp_socket) == FALSE) { + return FALSE; + } + if(bind == TRUE) { + if(mpf_socket_bind(stream->rtp_socket,local_media->ip.buf,local_media->port,stream->pool,&stream->rtp_l_sockaddr) == FALSE) { + apr_socket_close(stream->rtp_socket); + stream->rtp_socket = NULL; + return FALSE; + } + } + + /* Create and optionally bind RCTP socket. Continue in either way. */ + if(mpf_socket_create(stream->pool,&stream->rtcp_socket) == TRUE && bind == TRUE) { + if(mpf_socket_bind(stream->rtcp_socket,local_media->ip.buf,local_media->port+1,stream->pool,&stream->rtcp_l_sockaddr) == FALSE) { + apr_socket_close(stream->rtcp_socket); + stream->rtcp_socket = NULL; + } + } + return TRUE; +} + +/* Bind RTP/RTCP sockets */ +static apt_bool_t mpf_rtp_socket_pair_bind(mpf_rtp_stream_t *stream, mpf_rtp_media_descriptor_t *local_media) +{ + /* Bind RTP socket. Return FALSE in case of an error. */ + if(mpf_socket_bind(stream->rtp_socket,local_media->ip.buf,local_media->port,stream->pool,&stream->rtp_l_sockaddr) == FALSE) { + return FALSE; + } + + /* Try to bind RTCP socket. Continue in either way. */ + mpf_socket_bind(stream->rtcp_socket,local_media->ip.buf,local_media->port+1,stream->pool,&stream->rtcp_l_sockaddr); + return TRUE; +} + +/* Close RTP/RTCP sockets */ static void mpf_rtp_socket_pair_close(mpf_rtp_stream_t *stream) { if(stream->rtp_socket) { diff --git a/libs/unimrcp/libs/mpf/src/mpf_rtp_termination_factory.c b/libs/unimrcp/libs/mpf/src/mpf_rtp_termination_factory.c index 7b3cfa144f..497c33da41 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_rtp_termination_factory.c +++ b/libs/unimrcp/libs/mpf/src/mpf_rtp_termination_factory.c @@ -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,18 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mpf_rtp_termination_factory.c 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_rtp_termination_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ +#include #include "mpf_termination.h" #include "mpf_rtp_termination_factory.h" #include "mpf_rtp_stream.h" #include "apt_log.h" +typedef struct media_engine_slot_t media_engine_slot_t; typedef struct rtp_termination_factory_t rtp_termination_factory_t; + +struct media_engine_slot_t { + mpf_engine_t *media_engine; + mpf_rtp_config_t *rtp_config; +}; + struct rtp_termination_factory_t { mpf_termination_factory_t base; + mpf_rtp_config_t *config; + apr_array_header_t *media_engine_slots; + apr_pool_t *pool; }; static apt_bool_t mpf_rtp_termination_destroy(mpf_termination_t *termination) @@ -38,10 +49,20 @@ static apt_bool_t mpf_rtp_termination_add(mpf_termination_t *termination, void * mpf_rtp_termination_descriptor_t *rtp_descriptor = descriptor; mpf_audio_stream_t *audio_stream = termination->audio_stream; if(!audio_stream) { - rtp_termination_factory_t *termination_factory = (rtp_termination_factory_t*)termination->termination_factory; + int i; + media_engine_slot_t *slot; + rtp_termination_factory_t *rtp_termination_factory = (rtp_termination_factory_t*)termination->termination_factory; + mpf_rtp_config_t *rtp_config = rtp_termination_factory->config; + for(i=0; imedia_engine_slots->nelts; i++) { + slot = &APR_ARRAY_IDX(rtp_termination_factory->media_engine_slots,i,media_engine_slot_t); + if(slot->media_engine == termination->media_engine) { + rtp_config = slot->rtp_config; + break; + } + } audio_stream = mpf_rtp_stream_create( termination, - termination_factory->config, + rtp_config, rtp_descriptor->audio.settings, termination->pool); if(!audio_stream) { @@ -98,6 +119,68 @@ static mpf_termination_t* mpf_rtp_termination_create(mpf_termination_factory_t * return termination; } +static apt_bool_t mpf_rtp_factory_engine_assign(mpf_termination_factory_t *termination_factory, mpf_engine_t *media_engine) +{ + int i; + media_engine_slot_t *slot; + mpf_rtp_config_t *rtp_config; + rtp_termination_factory_t *rtp_termination_factory; + if(!termination_factory || !media_engine) { + return FALSE; + } + + rtp_termination_factory = (rtp_termination_factory_t *) termination_factory; + for(i=0; imedia_engine_slots->nelts; i++) { + slot = &APR_ARRAY_IDX(rtp_termination_factory->media_engine_slots,i,media_engine_slot_t); + if(slot->media_engine == media_engine) { + /* already exists, just return true */ + return TRUE; + } + } + + slot = apr_array_push(rtp_termination_factory->media_engine_slots); + slot->media_engine = media_engine; + rtp_config = mpf_rtp_config_alloc(rtp_termination_factory->pool); + *rtp_config = *rtp_termination_factory->config; + slot->rtp_config = rtp_config; + + if(rtp_termination_factory->media_engine_slots->nelts > 1) { + mpf_rtp_config_t *rtp_config_prev; + + /* split RTP port range evenly among assigned media engines */ + apr_uint16_t ports_per_engine = (apr_uint16_t)((rtp_termination_factory->config->rtp_port_max - rtp_termination_factory->config->rtp_port_min) / + rtp_termination_factory->media_engine_slots->nelts); + if(ports_per_engine % 2 != 0) { + /* number of ports per engine should be even (RTP/RTCP pair)*/ + ports_per_engine--; + } + /* rewrite max RTP port for the first slot */ + slot = &APR_ARRAY_IDX(rtp_termination_factory->media_engine_slots,0,media_engine_slot_t); + rtp_config_prev = slot->rtp_config; + rtp_config_prev->rtp_port_max = rtp_config_prev->rtp_port_min + ports_per_engine; + + /* rewrite cur, min and max RTP ports for the slots between first and last, if any */ + for(i=1; imedia_engine_slots->nelts-1; i++) { + slot = &APR_ARRAY_IDX(rtp_termination_factory->media_engine_slots,i,media_engine_slot_t); + rtp_config = slot->rtp_config; + rtp_config->rtp_port_min = rtp_config_prev->rtp_port_max; + rtp_config->rtp_port_max = rtp_config->rtp_port_min + ports_per_engine; + + rtp_config->rtp_port_cur = rtp_config->rtp_port_min; + + rtp_config_prev = rtp_config; + } + + /* rewrite cur and min but leave max RTP port for the last slot */ + slot = &APR_ARRAY_IDX(rtp_termination_factory->media_engine_slots, + rtp_termination_factory->media_engine_slots->nelts-1,media_engine_slot_t); + rtp_config = slot->rtp_config; + rtp_config->rtp_port_min = rtp_config_prev->rtp_port_max; + rtp_config->rtp_port_cur = rtp_config->rtp_port_min; + } + return TRUE; +} + MPF_DECLARE(mpf_termination_factory_t*) mpf_rtp_termination_factory_create( mpf_rtp_config_t *rtp_config, apr_pool_t *pool) @@ -109,7 +192,10 @@ MPF_DECLARE(mpf_termination_factory_t*) mpf_rtp_termination_factory_create( rtp_config->rtp_port_cur = rtp_config->rtp_port_min; rtp_termination_factory = apr_palloc(pool,sizeof(rtp_termination_factory_t)); rtp_termination_factory->base.create_termination = mpf_rtp_termination_create; + rtp_termination_factory->base.assign_engine = mpf_rtp_factory_engine_assign; + rtp_termination_factory->pool = pool; rtp_termination_factory->config = rtp_config; + rtp_termination_factory->media_engine_slots = apr_array_make(pool,1,sizeof(media_engine_slot_t)); apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create RTP Termination Factory %s:[%hu,%hu]", rtp_config->ip.buf, rtp_config->rtp_port_min, diff --git a/libs/unimrcp/libs/mpf/src/mpf_scheduler.c b/libs/unimrcp/libs/mpf/src/mpf_scheduler.c index 452799cbf9..dab8e6b067 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_scheduler.c +++ b/libs/unimrcp/libs/mpf/src/mpf_scheduler.c @@ -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: mpf_scheduler.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_scheduler.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_scheduler.h" @@ -188,6 +188,8 @@ MPF_DECLARE(apt_bool_t) mpf_scheduler_stop(mpf_scheduler_t *scheduler) #else +#include "apt_task.h" + static APR_INLINE void mpf_scheduler_init(mpf_scheduler_t *scheduler) { scheduler->thread = NULL; @@ -201,6 +203,9 @@ static void* APR_THREAD_FUNC timer_thread_proc(apr_thread_t *thread, void *data) apr_interval_time_t time_drift = 0; apr_time_t time_now, time_last; +#if APR_HAS_SETTHREADNAME + apr_thread_name_set("MPF Scheduler"); +#endif time_now = apr_time_now(); while(scheduler->running == TRUE) { time_last = time_now; diff --git a/libs/unimrcp/libs/mpf/src/mpf_stream.c b/libs/unimrcp/libs/mpf/src/mpf_stream.c index fa474c39c4..2c0c890aa2 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_stream.c +++ b/libs/unimrcp/libs/mpf/src/mpf_stream.c @@ -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: mpf_stream.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mpf_stream.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_stream.h" diff --git a/libs/unimrcp/libs/mpf/src/mpf_termination.c b/libs/unimrcp/libs/mpf/src/mpf_termination.c index e32589eed5..23e7a3aaaa 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_termination.c +++ b/libs/unimrcp/libs/mpf/src/mpf_termination.c @@ -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: mpf_termination.c 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_termination.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_termination.h" @@ -32,7 +32,7 @@ MPF_DECLARE(mpf_termination_t*) mpf_termination_base_create( termination->pool = pool; termination->name = "media-tm"; termination->obj = obj; - termination->event_handler_obj = NULL; + termination->media_engine = NULL; termination->event_handler = NULL; termination->codec_manager = NULL; termination->timer_queue = NULL; diff --git a/libs/unimrcp/libs/mpf/src/mpf_termination_factory.c b/libs/unimrcp/libs/mpf/src/mpf_termination_factory.c index 1823fd826a..f8d0034c8b 100644 --- a/libs/unimrcp/libs/mpf/src/mpf_termination_factory.c +++ b/libs/unimrcp/libs/mpf/src/mpf_termination_factory.c @@ -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,12 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mpf_termination_factory.c 1693 2010-05-16 18:33:07Z achaloyan $ + * $Id: mpf_termination_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mpf_termination_factory.h" #include "mpf_termination.h" +/** Assign media engine to termination factory */ +MPF_DECLARE(apt_bool_t) mpf_termination_factory_engine_assign( + mpf_termination_factory_t *termination_factory, + mpf_engine_t *media_engine) +{ + if(termination_factory && termination_factory->assign_engine && media_engine) { + return termination_factory->assign_engine(termination_factory,media_engine); + } + return FALSE; +} + /** Create MPF termination from termination factory */ MPF_DECLARE(mpf_termination_t*) mpf_termination_create( mpf_termination_factory_t *termination_factory, diff --git a/libs/unimrcp/libs/mrcp-client/Makefile.am b/libs/unimrcp/libs/mrcp-client/Makefile.am index 6cc15f0566..dfbacdcb77 100644 --- a/libs/unimrcp/libs/mrcp-client/Makefile.am +++ b/libs/unimrcp/libs/mrcp-client/Makefile.am @@ -1,4 +1,4 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-client/include \ -I$(top_srcdir)/libs/mrcp-signaling/include \ @@ -9,7 +9,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-client/include \ -I$(top_srcdir)/libs/mrcp/resources/include \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmrcpclient.la diff --git a/libs/unimrcp/libs/mrcp-client/include/mrcp_application.h b/libs/unimrcp/libs/mrcp-client/include/mrcp_application.h index 66b097b962..3770e77ece 100644 --- a/libs/unimrcp/libs/mrcp-client/include/mrcp_application.h +++ b/libs/unimrcp/libs/mrcp-client/include/mrcp_application.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: mrcp_application.h 1779 2010-09-01 05:54:34Z achaloyan $ + * $Id: mrcp_application.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_APPLICATION_H @@ -183,6 +183,12 @@ MRCP_DECLARE(apr_pool_t*) mrcp_application_session_pool_get(const mrcp_session_t */ MRCP_DECLARE(const apt_str_t*) mrcp_application_session_id_get(const mrcp_session_t *session); +/** + * Get SIP or RTSP response code. + * @param session the session to use + */ +MRCP_DECLARE(int) mrcp_application_session_response_code_get(const mrcp_session_t *session); + /** * Get external object associated with the session. * @param session the session to get object from diff --git a/libs/unimrcp/libs/mrcp-client/include/mrcp_client.h b/libs/unimrcp/libs/mrcp-client/include/mrcp_client.h index 9ddd5643bf..b34ce5b50b 100644 --- a/libs/unimrcp/libs/mrcp-client/include/mrcp_client.h +++ b/libs/unimrcp/libs/mrcp-client/include/mrcp_client.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: mrcp_client.h 1733 2010-06-07 17:26:49Z achaloyan $ + * $Id: mrcp_client.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_CLIENT_H @@ -143,6 +143,25 @@ MRCP_DECLARE(mrcp_profile_t*) mrcp_client_profile_create( mrcp_sig_settings_t *signaling_settings, apr_pool_t *pool); +/** Create MRCP profile (extended version) */ +MRCP_DECLARE(mrcp_profile_t*) mrcp_client_profile_create_ex( + mrcp_version_e mrcp_version, + mrcp_resource_factory_t *resource_factory, + mrcp_sa_factory_t *sa_factory, + mrcp_ca_factory_t *ca_factory, + mpf_engine_factory_t *mpf_factory, + mpf_termination_factory_t *rtp_factory, + mpf_rtp_settings_t *rtp_settings, + mrcp_sig_settings_t *signaling_settings, + apr_pool_t *pool); + +/** + * Set a tag to the profile. + * @param profile the profile to set a tag for + * @param tag the tag to set + */ +MRCP_DECLARE(void) mrcp_client_profile_tag_set(mrcp_profile_t *profile, const char *tag); + /** * Register MRCP profile. * @param client the MRCP client to set profile for @@ -214,6 +233,16 @@ MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_client_connection_agent_get(const mr */ MRCP_DECLARE(mrcp_profile_t*) mrcp_client_profile_get(const mrcp_client_t *client, const char *name); +/** + * Get available profiles. + * @param client the MRCP client to get the profile from + * @param profiles the array of profiles to be filled in + * @param count the max number of profiles on entry; and the number of profiles filled in on exit + * @param tag the tag to be used as a filter (no filter is specified if tag is NULL) + * @return FALSE if the provided max number of profiles is less than the actual number of profiles + */ +MRCP_DECLARE(apt_bool_t) mrcp_client_profiles_get(const mrcp_client_t *client, mrcp_profile_t *profiles[], apr_size_t *count, const char *tag); + /** * Get directory layout. * @param client the MRCP client to get from diff --git a/libs/unimrcp/libs/mrcp-client/include/mrcp_client_session.h b/libs/unimrcp/libs/mrcp-client/include/mrcp_client_session.h index 8944e122a9..cb73c3e496 100644 --- a/libs/unimrcp/libs/mrcp-client/include/mrcp_client_session.h +++ b/libs/unimrcp/libs/mrcp-client/include/mrcp_client_session.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: mrcp_client_session.h 1733 2010-06-07 17:26:49Z achaloyan $ + * $Id: mrcp_client_session.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_CLIENT_SESSION_H @@ -92,6 +92,8 @@ struct mrcp_client_session_t { mrcp_sig_status_code_e status; /** Number of in-progress sub requests */ apr_size_t subrequest_count; + /** True, if server unexpectedly closed session/connection */ + apt_bool_t disconnected; }; /** MRCP channel */ @@ -134,17 +136,22 @@ struct rtp_termination_slot_t { /** MRCP profile */ struct mrcp_profile_t { + /** Unique profile name */ + const char *name; + /** Arbitrary tag set/used by user application */ + const char *tag; + /** MRCP version */ + mrcp_version_e mrcp_version; /** MRCP resource factory */ mrcp_resource_factory_t *resource_factory; - /** Media processing engine */ - mpf_engine_t *media_engine; + /** Media engine factory */ + mpf_engine_factory_t *mpf_factory; /** RTP termination factory */ mpf_termination_factory_t *rtp_termination_factory; - /** Signaling agent */ - mrcp_sig_agent_t *signaling_agent; - /** Connection agent */ - mrcp_connection_agent_t *connection_agent; - + /** Signaling agent factory */ + mrcp_sa_factory_t *sa_factory; + /** Connection agent factory */ + mrcp_ca_factory_t *ca_factory; /** Signaling settings */ mrcp_sig_settings_t *signaling_settings; /** RTP settings */ diff --git a/libs/unimrcp/libs/mrcp-client/include/mrcp_client_types.h b/libs/unimrcp/libs/mrcp-client/include/mrcp_client_types.h index 4e3b783f06..8355b8669c 100644 --- a/libs/unimrcp/libs/mrcp-client/include/mrcp_client_types.h +++ b/libs/unimrcp/libs/mrcp-client/include/mrcp_client_types.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: mrcp_client_types.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_client_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_CLIENT_TYPES_H diff --git a/libs/unimrcp/libs/mrcp-client/mrcpclient.2008.vcproj b/libs/unimrcp/libs/mrcp-client/mrcpclient.2008.vcproj deleted file mode 100644 index 6123fef4c4..0000000000 --- a/libs/unimrcp/libs/mrcp-client/mrcpclient.2008.vcproj +++ /dev/null @@ -1,293 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp-client/mrcpclient.2010.vcxproj b/libs/unimrcp/libs/mrcp-client/mrcpclient.vcxproj similarity index 64% rename from libs/unimrcp/libs/mrcp-client/mrcpclient.2010.vcxproj rename to libs/unimrcp/libs/mrcp-client/mrcpclient.vcxproj index 7a9d7856c6..d33b64741f 100644 --- a/libs/unimrcp/libs/mrcp-client/mrcpclient.2010.vcxproj +++ b/libs/unimrcp/libs/mrcp-client/mrcpclient.vcxproj @@ -1,122 +1,125 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpclient - {72782932-37CC-46AE-8C7F-9A7B1A6EE108} - mrcpclient - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {72782932-37CC-46AE-8C7F-9A7B1A6EE108} + mrcpclient + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + X64 + + + ProgramDatabase + + + + + X64 + + + + + + + + + + + + + + + + {12a49562-bab9-43a3-a21d-15b60bbb4c31} + false + + + {a9edac04-6a5f-4ba7-bc0d-cce7b255b6ea} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2012.vcxproj.filters b/libs/unimrcp/libs/mrcp-client/mrcpclient.vcxproj.filters similarity index 63% rename from libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2012.vcxproj.filters rename to libs/unimrcp/libs/mrcp-client/mrcpclient.vcxproj.filters index 4e5d30c3da..789830de35 100644 --- a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2012.vcxproj.filters +++ b/libs/unimrcp/libs/mrcp-client/mrcpclient.vcxproj.filters @@ -1,35 +1,38 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {f3dc550f-1a0f-4b9e-b077-3b6940dc5531} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - include - - - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {dc4325fe-8e7a-4a40-ab63-4173d85cf131} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-client/src/mrcp_application.c b/libs/unimrcp/libs/mrcp-client/src/mrcp_application.c index f3b73af544..f4eff6bd50 100644 --- a/libs/unimrcp/libs/mrcp-client/src/mrcp_application.c +++ b/libs/unimrcp/libs/mrcp-client/src/mrcp_application.c @@ -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,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mrcp_application.c 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_application.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_application.h" #include "mrcp_client.h" #include "mrcp_client_session.h" +#include "mrcp_session_descriptor.h" #include "mrcp_message.h" #include "mrcp_sig_agent.h" #include "mrcp_resource_factory.h" @@ -92,7 +93,7 @@ MRCP_DECLARE(mrcp_session_t*) mrcp_application_session_create(mrcp_application_t session->base.log_obj = obj; session->profile = profile; - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCP Handle "APT_PTR_FMT" [%s]", + apt_obj_log(APT_LOG_MARK,APT_PRIO_NOTICE,session->base.log_obj,"Create MRCP Handle "APT_PTR_FMT" [%s]", MRCP_SESSION_PTR(session), profile_name); return &session->base; @@ -116,6 +117,16 @@ MRCP_DECLARE(const apt_str_t*) mrcp_application_session_id_get(const mrcp_sessio return &session->id; } +/** Get SIP or RTSP response code */ +MRCP_DECLARE(int) mrcp_application_session_response_code_get(const mrcp_session_t *session) +{ + mrcp_client_session_t *client_session = (mrcp_client_session_t*)session; + if(!client_session || !client_session->answer) { + return 0; + } + return client_session->answer->response_code; +} + /** Get external object associated with the session */ MRCP_DECLARE(void*) mrcp_application_session_object_get(const mrcp_session_t *session) { @@ -168,7 +179,7 @@ MRCP_DECLARE(apt_bool_t) mrcp_application_session_destroy(mrcp_session_t *sessio if(!session) { return FALSE; } - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy MRCP Handle %s",session->name); + apt_obj_log(APT_LOG_MARK,APT_PRIO_NOTICE,session->log_obj,"Destroy MRCP Handle %s",session->name); mrcp_session_destroy(session); return TRUE; } @@ -203,7 +214,7 @@ MRCP_DECLARE(mrcp_channel_t*) mrcp_application_channel_create( if(termination) { /* Media engine and RTP factory must be specified in this case */ - if(!profile->media_engine || !profile->rtp_termination_factory) { + if(!profile->mpf_factory || !profile->rtp_termination_factory) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Channel: invalid profile"); return FALSE; } @@ -317,7 +328,7 @@ MRCP_DECLARE(mrcp_message_t*) mrcp_application_message_create(mrcp_session_t *se } mrcp_message = mrcp_request_create( channel->resource, - profile->signaling_agent->mrcp_version, + profile->mrcp_version, method_id, session->pool); return mrcp_message; diff --git a/libs/unimrcp/libs/mrcp-client/src/mrcp_client.c b/libs/unimrcp/libs/mrcp-client/src/mrcp_client.c index 7689cf37ef..0993187aba 100644 --- a/libs/unimrcp/libs/mrcp-client/src/mrcp_client.c +++ b/libs/unimrcp/libs/mrcp-client/src/mrcp_client.c @@ -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: mrcp_client.c 1733 2010-06-07 17:26:49Z achaloyan $ + * $Id: mrcp_client.c 2234 2014-11-12 01:38:17Z achaloyan@gmail.com $ */ #include @@ -22,6 +22,8 @@ #include "mrcp_sig_agent.h" #include "mrcp_client_session.h" #include "mrcp_client_connection.h" +#include "mrcp_ca_factory.h" +#include "mpf_engine_factory.h" #include "apt_consumer_task.h" #include "apt_pool.h" #include "apt_log.h" @@ -478,37 +480,115 @@ MRCP_DECLARE(mrcp_profile_t*) mrcp_client_profile_create( mpf_rtp_settings_t *rtp_settings, mrcp_sig_settings_t *signaling_settings, apr_pool_t *pool) +{ + mrcp_sa_factory_t *sa_factory = NULL; + mrcp_ca_factory_t *ca_factory = NULL; + mpf_engine_factory_t *mpf_factory = NULL; + mrcp_version_e mrcp_version = MRCP_VERSION_2; + if(!connection_agent) + mrcp_version = MRCP_VERSION_1; + + if(signaling_agent) { + sa_factory = mrcp_sa_factory_create(pool); + mrcp_sa_factory_agent_add(sa_factory,signaling_agent); + } + + if(connection_agent) { + ca_factory = mrcp_ca_factory_create(pool); + mrcp_ca_factory_agent_add(ca_factory,connection_agent); + } + + if(media_engine) { + mpf_factory = mpf_engine_factory_create(pool); + mpf_engine_factory_engine_add(mpf_factory,media_engine); + } + + return mrcp_client_profile_create_ex( + mrcp_version, + resource_factory, + sa_factory, + ca_factory, + mpf_factory, + rtp_factory, + rtp_settings, + signaling_settings, + pool); +} + +/** Create MRCP profile (extended version) */ +MRCP_DECLARE(mrcp_profile_t*) mrcp_client_profile_create_ex( + mrcp_version_e mrcp_version, + mrcp_resource_factory_t *resource_factory, + mrcp_sa_factory_t *sa_factory, + mrcp_ca_factory_t *ca_factory, + mpf_engine_factory_t *mpf_factory, + mpf_termination_factory_t *rtp_factory, + mpf_rtp_settings_t *rtp_settings, + mrcp_sig_settings_t *signaling_settings, + apr_pool_t *pool) { mrcp_profile_t *profile = apr_palloc(pool,sizeof(mrcp_profile_t)); + profile->name = NULL; + profile->tag = NULL; + profile->mrcp_version = mrcp_version; profile->resource_factory = resource_factory; - profile->media_engine = media_engine; + profile->mpf_factory = mpf_factory; profile->rtp_termination_factory = rtp_factory; profile->rtp_settings = rtp_settings; - profile->signaling_agent = signaling_agent; - profile->connection_agent = connection_agent; + profile->sa_factory = sa_factory; + profile->ca_factory = ca_factory; profile->signaling_settings = signaling_settings; + + if(mpf_factory && rtp_factory) + mpf_engine_factory_rtp_factory_assign(mpf_factory,rtp_factory); return profile; } +/** Set a tag to the profile */ +MRCP_DECLARE(void) mrcp_client_profile_tag_set(mrcp_profile_t *profile, const char *tag) +{ + if(profile) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Profile Tag [%s]",tag); + profile->tag = tag; + } +} + /** Register MRCP profile */ MRCP_DECLARE(apt_bool_t) mrcp_client_profile_register(mrcp_client_t *client, mrcp_profile_t *profile, const char *name) { if(!profile || !name) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile: no name",name); + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile: no name"); return FALSE; } if(!profile->resource_factory) { profile->resource_factory = client->resource_factory; } - if(!profile->signaling_agent) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing signaling agent",name); + if(!profile->sa_factory) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing signaling agent factory",name); return FALSE; } - if(profile->signaling_agent->mrcp_version == MRCP_VERSION_2 && - !profile->connection_agent) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing connection agent",name); + if(mrcp_sa_factory_is_empty(profile->sa_factory) == TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: empty signaling agent factory",name); return FALSE; } + if(profile->mrcp_version == MRCP_VERSION_2) { + if(!profile->ca_factory) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing connection agent factory",name); + return FALSE; + } + if(mrcp_ca_factory_is_empty(profile->ca_factory) == TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: empty connection agent factory",name); + return FALSE; + } + } + + /* mpf_factory may not be specified; but if it is specified, it must not be empty */ + if(profile->mpf_factory) { + if(mpf_engine_factory_is_empty(profile->mpf_factory) == TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: empty media engine factory",name); + return FALSE; + } + } if(!profile->signaling_settings) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing signaling settings",name); @@ -517,6 +597,7 @@ MRCP_DECLARE(apt_bool_t) mrcp_client_profile_register(mrcp_client_t *client, mrc apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Register Profile [%s]",name); apr_hash_set(client->profile_table,name,APR_HASH_KEY_STRING,profile); + profile->name = name; return TRUE; } @@ -526,6 +607,38 @@ MRCP_DECLARE(mrcp_profile_t*) mrcp_client_profile_get(const mrcp_client_t *clien return apr_hash_get(client->profile_table,name,APR_HASH_KEY_STRING); } +/** Get available profiles */ +MRCP_DECLARE(apt_bool_t) mrcp_client_profiles_get(const mrcp_client_t *client, mrcp_profile_t *profiles[], apr_size_t *count, const char *tag) +{ + apr_hash_index_t *it; + void *val; + mrcp_profile_t *profile; + apr_size_t i = 0; + apt_bool_t status = TRUE; + + if(!profiles || !count) { + return FALSE; + } + + for(it = apr_hash_first(client->pool, client->profile_table); it; it = apr_hash_next(it)) { + apr_hash_this(it, NULL, NULL, &val); + if(!val) continue; + + if(i >= *count) { + status = FALSE; + break; + } + + profile = val; + if(!tag || (profile->tag && strcasecmp(tag,profile->tag) == 0)) { + profiles[i] = profile; + i++; + } + } + *count = i; + return status; +} + /** Register MRCP application */ MRCP_DECLARE(apt_bool_t) mrcp_client_application_register(mrcp_client_t *client, mrcp_application_t *application, const char *name) { @@ -575,6 +688,7 @@ mrcp_client_session_t* mrcp_client_session_create(mrcp_client_t *client) session->request_queue = apt_list_create(pool); session->mpf_task_msg = NULL; session->subrequest_count = 0; + session->disconnected = FALSE; session->state = SESSION_STATE_NONE; session->status = MRCP_SIG_STATUS_CODE_SUCCESS; return session; @@ -583,20 +697,20 @@ mrcp_client_session_t* mrcp_client_session_create(mrcp_client_t *client) void mrcp_client_session_add(mrcp_client_t *client, mrcp_client_session_t *session) { if(session) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add MRCP Handle "APT_NAMESID_FMT, + apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Add MRCP Handle "APT_NAMESID_FMT, session->base.name, MRCP_SESSION_SID(&session->base)); - apr_hash_set(client->session_table,session,sizeof(session),session); + apr_hash_set(client->session_table,session,sizeof(void*),session); } } void mrcp_client_session_remove(mrcp_client_t *client, mrcp_client_session_t *session) { if(session) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove MRCP Handle "APT_NAMESID_FMT, + apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Remove MRCP Handle "APT_NAMESID_FMT, session->base.name, MRCP_SESSION_SID(&session->base)); - apr_hash_set(client->session_table,session,sizeof(session),NULL); + apr_hash_set(client->session_table,session,sizeof(void*),NULL); } } @@ -719,8 +833,9 @@ apt_bool_t mrcp_app_signaling_task_msg_signal(mrcp_sig_command_e command_id, mrc app_message->control_message = NULL; app_message->descriptor = NULL; *slot = app_message; + return apt_task_msg_signal(task,task_msg); } - return apt_task_msg_signal(task,task_msg); + return FALSE; } apt_bool_t mrcp_app_control_task_msg_signal(mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message) @@ -740,22 +855,25 @@ apt_bool_t mrcp_app_control_task_msg_signal(mrcp_session_t *session, mrcp_channe app_message->channel = channel; app_message->control_message = message; *slot = app_message; + return apt_task_msg_signal(task,task_msg); } - return apt_task_msg_signal(task,task_msg); + return FALSE; } static apt_bool_t mrcp_client_signaling_task_msg_signal(sig_agent_task_msg_type_e type, mrcp_session_t *session, mrcp_session_descriptor_t *descriptor, mrcp_message_t *message) { sig_agent_task_msg_data_t *data; apt_task_msg_t *task_msg = apt_task_msg_acquire(session->signaling_agent->msg_pool); - task_msg->type = MRCP_CLIENT_SIGNALING_TASK_MSG; - task_msg->sub_type = type; - data = (sig_agent_task_msg_data_t*) task_msg->data; - data->session = (mrcp_client_session_t*)session; - data->descriptor = descriptor; - data->message = message; - - return apt_task_msg_parent_signal(session->signaling_agent->task,task_msg); + if(task_msg) { + task_msg->type = MRCP_CLIENT_SIGNALING_TASK_MSG; + task_msg->sub_type = type; + data = (sig_agent_task_msg_data_t*) task_msg->data; + data->session = (mrcp_client_session_t*)session; + data->descriptor = descriptor; + data->message = message; + return apt_task_msg_parent_signal(session->signaling_agent->task,task_msg); + } + return FALSE; } static apt_bool_t mrcp_client_connection_task_msg_signal( @@ -775,15 +893,17 @@ static apt_bool_t mrcp_client_connection_task_msg_signal( } task = apt_consumer_task_base_get(client->task); task_msg = apt_task_msg_acquire(client->cnt_msg_pool); - task_msg->type = MRCP_CLIENT_CONNECTION_TASK_MSG; - task_msg->sub_type = type; - data = (connection_agent_task_msg_data_t*) task_msg->data; - data->channel = channel ? channel->obj : NULL; - data->descriptor = descriptor; - data->message = message; - data->status = status; - - return apt_task_msg_signal(task,task_msg); + if(task_msg) { + task_msg->type = MRCP_CLIENT_CONNECTION_TASK_MSG; + task_msg->sub_type = type; + data = (connection_agent_task_msg_data_t*) task_msg->data; + data->channel = channel ? channel->obj : NULL; + data->descriptor = descriptor; + data->message = message; + data->status = status; + return apt_task_msg_signal(task,task_msg); + } + return FALSE; } diff --git a/libs/unimrcp/libs/mrcp-client/src/mrcp_client_session.c b/libs/unimrcp/libs/mrcp-client/src/mrcp_client_session.c index b7c8db3bb7..97af3cb10a 100644 --- a/libs/unimrcp/libs/mrcp-client/src/mrcp_client_session.c +++ b/libs/unimrcp/libs/mrcp-client/src/mrcp_client_session.c @@ -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: mrcp_client_session.c 1799 2011-05-12 02:32:32Z achaloyan $ + * $Id: mrcp_client_session.c 2237 2014-11-12 01:48:46Z achaloyan@gmail.com $ */ #include "mrcp_client_session.h" @@ -25,6 +25,8 @@ #include "mrcp_session_descriptor.h" #include "mrcp_control_descriptor.h" #include "mrcp_message.h" +#include "mrcp_ca_factory.h" +#include "mpf_engine_factory.h" #include "mpf_termination_factory.h" #include "mpf_stream.h" #include "apt_consumer_task.h" @@ -35,6 +37,9 @@ #define MRCP_SESSION_NAMESID(session) \ session->base.name, MRCP_SESSION_SID(&session->base) +#define IS_SESSION_TERMINATE(app_message) \ + (app_message->message_type == MRCP_APP_MESSAGE_TYPE_SIGNALING && \ + app_message->sig_message.command_id == MRCP_SIG_COMMAND_SESSION_TERMINATE) void mrcp_client_session_add(mrcp_client_t *client, mrcp_client_session_t *session); void mrcp_client_session_remove(mrcp_client_t *client, mrcp_client_session_t *session); @@ -56,13 +61,17 @@ static mrcp_channel_t* mrcp_client_channel_find_by_name(mrcp_client_session_t *s static APR_INLINE mrcp_version_e mrcp_session_version_get(mrcp_client_session_t *session) { - return session->base.signaling_agent->mrcp_version; + return session->profile->mrcp_version; } static APR_INLINE void mrcp_client_session_state_set(mrcp_client_session_t *session, mrcp_client_session_state_e state) { if(session->subrequest_count != 0) { /* error case */ + apt_obj_log(APT_LOG_MARK,APT_PRIO_ERROR,session->base.log_obj,"Unexpected State Change [%d] pending subrequests [%d] "APT_NAMESID_FMT, + state, + session->subrequest_count, + MRCP_SESSION_NAMESID(session)); session->subrequest_count = 0; } session->state = state; @@ -139,43 +148,49 @@ apt_bool_t mrcp_client_session_answer_process(mrcp_client_session_t *session, mr return mrcp_app_sig_response_raise(session,TRUE); } - apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Receive Answer "APT_NAMESID_FMT" [c:%d a:%d v:%d]", + apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Receive Answer "APT_NAMESID_FMT" [c:%d a:%d v:%d] Status %d", MRCP_SESSION_NAMESID(session), descriptor->control_media_arr->nelts, descriptor->audio_media_arr->nelts, - descriptor->video_media_arr->nelts); + descriptor->video_media_arr->nelts, + descriptor->response_code); - mrcp_client_session_state_set(session,SESSION_STATE_PROCESSING_ANSWER); - if(session->context) { - /* first, reset/destroy existing associations and topology */ - if(mpf_engine_topology_message_add( - session->profile->media_engine, - MPF_RESET_ASSOCIATIONS,session->context, - &session->mpf_task_msg) == TRUE){ - mrcp_client_session_subrequest_add(session); + if(descriptor->response_code >=200 && descriptor->response_code < 300) { + mrcp_client_session_state_set(session,SESSION_STATE_PROCESSING_ANSWER); + if(session->context) { + /* first, reset/destroy existing associations and topology */ + if(mpf_engine_topology_message_add( + session->base.media_engine, + MPF_RESET_ASSOCIATIONS,session->context, + &session->mpf_task_msg) == TRUE){ + mrcp_client_session_subrequest_add(session); + } } - } - if(mrcp_session_version_get(session) == MRCP_VERSION_1) { - if(mrcp_client_resource_answer_process(session,descriptor) != TRUE) { - session->status = MRCP_SIG_STATUS_CODE_FAILURE; + if(mrcp_session_version_get(session) == MRCP_VERSION_1) { + if(mrcp_client_resource_answer_process(session,descriptor) != TRUE) { + session->status = MRCP_SIG_STATUS_CODE_FAILURE; + } + } + else { + mrcp_client_control_media_answer_process(session,descriptor); + mrcp_client_av_media_answer_process(session,descriptor); + } + + if(session->context) { + /* apply topology based on assigned associations */ + if(mpf_engine_topology_message_add( + session->base.media_engine, + MPF_APPLY_TOPOLOGY,session->context, + &session->mpf_task_msg) == TRUE) { + mrcp_client_session_subrequest_add(session); + } + + mpf_engine_message_send(session->base.media_engine,&session->mpf_task_msg); } } else { - mrcp_client_control_media_answer_process(session,descriptor); - mrcp_client_av_media_answer_process(session,descriptor); - } - - if(session->context) { - /* apply topology based on assigned associations */ - if(mpf_engine_topology_message_add( - session->profile->media_engine, - MPF_APPLY_TOPOLOGY,session->context, - &session->mpf_task_msg) == TRUE) { - mrcp_client_session_subrequest_add(session); - } - - mpf_engine_message_send(session->profile->media_engine,&session->mpf_task_msg); + session->status = MRCP_SIG_STATUS_CODE_TERMINATE; } /* store received answer */ @@ -208,35 +223,15 @@ apt_bool_t mrcp_client_session_terminate_event_process(mrcp_client_session_t *se MRCP_SESSION_NAMESID(session)); return FALSE; } - - if(session->active_request) { - /* raise app response */ - session->status = MRCP_SIG_STATUS_CODE_TERMINATE; - mrcp_app_failure_message_raise(session); - /* cancel remaing requests, but do process session termination request (if any) */ - do { - session->active_request = apt_list_pop_front(session->request_queue); - if(session->active_request) { - const mrcp_app_message_t *app_message = session->active_request; - if(app_message->message_type == MRCP_APP_MESSAGE_TYPE_SIGNALING && - app_message->sig_message.command_id == MRCP_SIG_COMMAND_SESSION_TERMINATE) { - /* process session termination */ - mrcp_app_request_dispatch(session,app_message); - break; - } - - /* cancel pending request */ - session->status = MRCP_SIG_STATUS_CODE_CANCEL; - mrcp_app_failure_message_raise(session); - } - } - while(session->active_request); - } - else { + apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Mark Session as Disconnected "APT_NAMESID_FMT, + MRCP_SESSION_NAMESID(session)); + session->disconnected = TRUE; + if(!session->active_request) { /* raise app event */ mrcp_app_sig_event_raise(session,NULL); } + return TRUE; } @@ -453,6 +448,9 @@ static apt_bool_t mrcp_app_sig_response_raise(mrcp_client_session_t *session, ap return FALSE; } session->active_request = NULL; + if(session->disconnected == TRUE) { + session->status = MRCP_SIG_STATUS_CODE_TERMINATE; + } response = mrcp_client_app_response_create(request,session->status,session->base.pool); apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Raise App Response "APT_NAMESID_FMT" [%d] %s [%d]", MRCP_SESSION_NAMESID(session), @@ -571,7 +569,7 @@ static rtp_termination_slot_t* mrcp_client_rtp_termination_find(mrcp_client_sess rtp_termination_slot_t *slot; for(i=0; iterminations->nelts; i++) { slot = &APR_ARRAY_IDX(session->terminations,i,rtp_termination_slot_t); - if(slot && slot->termination == termination) { + if(slot->termination == termination) { return slot; } } @@ -705,7 +703,7 @@ static apt_bool_t mrcp_client_channel_add(mrcp_client_session_t *session, mrcp_c else { mrcp_control_descriptor_t *control_media; if(!channel->control_channel) { - channel->control_channel = mrcp_client_control_channel_create(profile->connection_agent,channel,pool); + channel->control_channel = mrcp_client_control_channel_create(session->base.connection_agent,channel,pool); mrcp_client_control_channel_log_obj_set(channel->control_channel,session->base.log_obj); } control_media = mrcp_control_offer_create(pool); @@ -740,7 +738,7 @@ static apt_bool_t mrcp_client_channel_add(mrcp_client_session_t *session, mrcp_c if(!session->context) { /* create media context first */ session->context = mpf_engine_context_create( - profile->media_engine, + session->base.media_engine, session->base.name, session,5,pool); } @@ -748,7 +746,7 @@ static apt_bool_t mrcp_client_channel_add(mrcp_client_session_t *session, mrcp_c MRCP_SESSION_NAMESID(session), mpf_termination_name_get(channel->termination)); if(mpf_engine_termination_message_add( - profile->media_engine, + session->base.media_engine, MPF_ADD_TERMINATION,session->context,channel->termination,NULL, &session->mpf_task_msg) == TRUE) { channel->waiting_for_termination = TRUE; @@ -767,10 +765,14 @@ static apt_bool_t mrcp_client_channel_add(mrcp_client_session_t *session, mrcp_c media->state = MPF_MEDIA_ENABLED; media->direction = mpf_stream_reverse_direction_get(audio_stream->direction); rtp_descriptor->audio.local = media; + if(audio_stream->capabilities) { + rtp_descriptor->audio.capabilities = mpf_stream_capabilities_clone(audio_stream->capabilities,pool); + rtp_descriptor->audio.capabilities->direction = media->direction; + } } /* create rtp termination */ - termination = mpf_termination_create(profile->rtp_termination_factory,session,pool); + termination = mpf_termination_create(session->base.rtp_factory,session,pool); slot->termination = termination; apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Add Media Termination "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), @@ -778,13 +780,13 @@ static apt_bool_t mrcp_client_channel_add(mrcp_client_session_t *session, mrcp_c /* send add termination request (add to media context) */ if(mpf_engine_termination_message_add( - profile->media_engine, + session->base.media_engine, MPF_ADD_TERMINATION,session->context,termination,rtp_descriptor, &session->mpf_task_msg) == TRUE) { slot->waiting = TRUE; mrcp_client_session_subrequest_add(session); } - mpf_engine_message_send(profile->media_engine,&session->mpf_task_msg); + mpf_engine_message_send(session->base.media_engine,&session->mpf_task_msg); } else { /* bypass media mode */ @@ -799,7 +801,7 @@ static apt_bool_t mrcp_client_channel_add(mrcp_client_session_t *session, mrcp_c slot->id = session->offer->audio_media_arr->nelts - 1; } } - } + } } slot->descriptor = rtp_descriptor; @@ -824,20 +826,18 @@ static apt_bool_t mrcp_client_session_update(mrcp_client_session_t *session) static apt_bool_t mrcp_client_session_terminate(mrcp_client_session_t *session) { - mrcp_profile_t *profile; mrcp_channel_t *channel; rtp_termination_slot_t *slot; int i; apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Terminate Session "APT_NAMESID_FMT, MRCP_SESSION_NAMESID(session)); - profile = session->profile; mrcp_client_session_state_set(session,SESSION_STATE_TERMINATING); if(session->context) { /* first destroy existing topology */ if(mpf_engine_topology_message_add( - session->profile->media_engine, + session->base.media_engine, MPF_DESTROY_TOPOLOGY,session->context, &session->mpf_task_msg) == TRUE){ mrcp_client_session_subrequest_add(session); @@ -865,7 +865,7 @@ static apt_bool_t mrcp_client_session_terminate(mrcp_client_session_t *session) MRCP_SESSION_NAMESID(session), mpf_termination_name_get(channel->termination)); if(mpf_engine_termination_message_add( - profile->media_engine, + session->base.media_engine, MPF_SUBTRACT_TERMINATION,session->context,channel->termination,NULL, &session->mpf_task_msg) == TRUE) { channel->waiting_for_termination = TRUE; @@ -879,14 +879,14 @@ static apt_bool_t mrcp_client_session_terminate(mrcp_client_session_t *session) for(i=0; iterminations->nelts; i++) { /* get existing termination */ slot = &APR_ARRAY_IDX(session->terminations,i,rtp_termination_slot_t); - if(!slot || !slot->termination) continue; + if(!slot->termination) continue; /* send subtract termination request */ apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Subtract Media Termination "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(slot->termination)); if(mpf_engine_termination_message_add( - profile->media_engine, + session->base.media_engine, MPF_SUBTRACT_TERMINATION,session->context,slot->termination,NULL, &session->mpf_task_msg) == TRUE) { slot->waiting = TRUE; @@ -894,7 +894,7 @@ static apt_bool_t mrcp_client_session_terminate(mrcp_client_session_t *session) } } - mpf_engine_message_send(profile->media_engine,&session->mpf_task_msg); + mpf_engine_message_send(session->base.media_engine,&session->mpf_task_msg); } mrcp_client_session_subrequest_add(session); @@ -941,9 +941,6 @@ static apt_bool_t mrcp_client_resource_discover(mrcp_client_session_t *session) static apt_bool_t mrcp_client_on_termination_add(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; - if(!session) { - return FALSE; - } apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Media Termination Added "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); @@ -985,9 +982,6 @@ static apt_bool_t mrcp_client_on_termination_add(mrcp_client_session_t *session, static apt_bool_t mrcp_client_on_termination_modify(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; - if(!session) { - return FALSE; - } apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Media Termination Modified "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); @@ -1017,9 +1011,6 @@ static apt_bool_t mrcp_client_on_termination_modify(mrcp_client_session_t *sessi static apt_bool_t mrcp_client_on_termination_subtract(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; - if(!session) { - return FALSE; - } apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Media Termination Subtracted "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); @@ -1061,6 +1052,10 @@ apt_bool_t mrcp_client_mpf_message_process(mpf_message_container_t *mpf_message_ else { session = NULL; } + if(!session) { + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Received MPF Message: NULL session"); + continue; + } if(mpf_message->message_type == MPF_MESSAGE_TYPE_RESPONSE) { switch(mpf_message->command_id) { case MPF_ADD_TERMINATION: @@ -1093,7 +1088,7 @@ apt_bool_t mrcp_client_mpf_message_process(mpf_message_container_t *mpf_message_ } } else if(mpf_message->message_type == MPF_MESSAGE_TYPE_EVENT) { - apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Process MPF Event "APT_NAMESID_FMT, + apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Process MPF Event "APT_NAMESID_FMT, MRCP_SESSION_NAMESID(session)); } } @@ -1170,8 +1165,6 @@ static apt_bool_t mrcp_client_av_media_answer_process(mrcp_client_session_t *ses mpf_rtp_termination_descriptor_t *rtp_descriptor; /* get existing termination */ slot = &APR_ARRAY_IDX(session->terminations,i,rtp_termination_slot_t); - if(!slot) continue; - remote_media = mrcp_session_audio_media_get(descriptor,i); if(slot->descriptor) { slot->descriptor->audio.remote = remote_media; @@ -1188,7 +1181,7 @@ static apt_bool_t mrcp_client_av_media_answer_process(mrcp_client_session_t *ses MRCP_SESSION_NAMESID(session), mpf_termination_name_get(slot->termination)); if(mpf_engine_termination_message_add( - session->profile->media_engine, + session->base.media_engine, MPF_MODIFY_TERMINATION,session->context,slot->termination,rtp_descriptor, &session->mpf_task_msg) == TRUE) { slot->waiting = TRUE; @@ -1196,7 +1189,7 @@ static apt_bool_t mrcp_client_av_media_answer_process(mrcp_client_session_t *ses } if(slot->channel && slot->channel->termination) { if(mpf_engine_assoc_message_add( - session->profile->media_engine, + session->base.media_engine, MPF_ADD_ASSOCIATION,session->context,slot->termination,slot->channel->termination, &session->mpf_task_msg) == TRUE) { mrcp_client_session_subrequest_add(session); @@ -1217,10 +1210,68 @@ static apt_bool_t mrcp_app_request_dispatch(mrcp_client_session_t *session, cons app_message->sig_message.command_id); return FALSE; } - + + if(session->disconnected == TRUE) { + /* cancel all the requests besides session termination one */ + if(!IS_SESSION_TERMINATE(app_message)) { + apt_obj_log(APT_LOG_MARK,APT_PRIO_WARNING,session->base.log_obj,"Cancel App Request "APT_NAMESID_FMT" [%d]", + MRCP_SESSION_NAMESID(session), app_message->sig_message.command_id); + session->status = MRCP_SIG_STATUS_CODE_CANCEL; + return mrcp_app_failure_message_raise(session); + } + } + if(session->registered == FALSE) { - session->base.signaling_agent = session->profile->signaling_agent; - session->base.signaling_agent->create_client_session(&session->base,session->profile->signaling_settings); + if(IS_SESSION_TERMINATE(app_message)) { + /* if session is not registered, nothing to terminate, just respond with success */ + session->status = MRCP_SIG_STATUS_CODE_SUCCESS; + return mrcp_app_sig_response_raise(session,FALSE); + } + + /* select signaling agent */ + session->base.signaling_agent = mrcp_sa_factory_agent_select(session->profile->sa_factory); + if(!session->base.signaling_agent) { + apt_obj_log(APT_LOG_MARK,APT_PRIO_WARNING,session->base.log_obj,"Failed to Select Signaling Agent "APT_NAMESID_FMT" [%d]", + MRCP_SESSION_NAMESID(session), + app_message->sig_message.command_id); + session->status = MRCP_SIG_STATUS_CODE_FAILURE; + } + if(session->profile->mrcp_version == MRCP_VERSION_2) { + /* select connection agent */ + session->base.connection_agent = mrcp_ca_factory_agent_select(session->profile->ca_factory); + if(!session->base.connection_agent) { + apt_obj_log(APT_LOG_MARK,APT_PRIO_WARNING,session->base.log_obj,"Failed to Select Connection Agent "APT_NAMESID_FMT" [%d]", + MRCP_SESSION_NAMESID(session), + app_message->sig_message.command_id); + session->status = MRCP_SIG_STATUS_CODE_FAILURE; + } + } + if(session->profile->mpf_factory) { + /* select media engine */ + session->base.media_engine = mpf_engine_factory_engine_select(session->profile->mpf_factory); + if(!session->base.media_engine) { + apt_obj_log(APT_LOG_MARK,APT_PRIO_WARNING,session->base.log_obj,"Failed to Select Media Engine "APT_NAMESID_FMT" [%d]", + MRCP_SESSION_NAMESID(session), + app_message->sig_message.command_id); + session->status = MRCP_SIG_STATUS_CODE_FAILURE; + } + } + /* set rtp termination factory */ + session->base.rtp_factory = session->profile->rtp_termination_factory; + + if(session->status == MRCP_SIG_STATUS_CODE_FAILURE) { + /* raise app response in case of failure */ + return mrcp_app_failure_message_raise(session); + } + + if(session->base.signaling_agent->create_client_session(&session->base,session->profile->signaling_settings) != TRUE) { + /* raise app response */ + apt_obj_log(APT_LOG_MARK,APT_PRIO_WARNING,session->base.log_obj,"Failed to Create Session "APT_NAMESID_FMT" [%d]", + MRCP_SESSION_NAMESID(session), + app_message->sig_message.command_id); + session->status = MRCP_SIG_STATUS_CODE_FAILURE; + return mrcp_app_failure_message_raise(session); + } mrcp_client_session_add(session->application->client,session); session->registered = TRUE; diff --git a/libs/unimrcp/libs/mrcp-engine/Makefile.am b/libs/unimrcp/libs/mrcp-engine/Makefile.am index f8edd77ba6..a67c910526 100644 --- a/libs/unimrcp/libs/mrcp-engine/Makefile.am +++ b/libs/unimrcp/libs/mrcp-engine/Makefile.am @@ -1,4 +1,4 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-engine/include \ -I$(top_srcdir)/libs/mrcp/include \ @@ -7,7 +7,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-engine/include \ -I$(top_srcdir)/libs/mrcp/resources/include \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmrcpengine.la diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_factory.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_factory.h index b86192eff6..d769a0a937 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_factory.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_factory.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: mrcp_engine_factory.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_engine_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_ENGINE_FACTORY_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_iface.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_iface.h index e602b7d836..2e70c80dec 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_iface.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_iface.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: mrcp_engine_iface.h 1677 2010-05-01 18:45:50Z achaloyan $ + * $Id: mrcp_engine_iface.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_ENGINE_IFACE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_impl.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_impl.h index 915d1e53f5..6900b6abe0 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_impl.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_impl.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: mrcp_engine_impl.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_engine_impl.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_ENGINE_IMPL_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_loader.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_loader.h index f6a47b8fa2..a408497266 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_loader.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_loader.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: mrcp_engine_loader.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_engine_loader.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_ENGINE_LOADER_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_plugin.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_plugin.h index 50a5391ef3..e9cdb6da9b 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_plugin.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_plugin.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: mrcp_engine_plugin.h 1724 2010-06-02 18:42:20Z achaloyan $ + * $Id: mrcp_engine_plugin.h 2139 2014-07-07 05:06:19Z achaloyan@gmail.com $ */ #ifndef MRCP_ENGINE_PLUGIN_H @@ -30,11 +30,18 @@ APT_BEGIN_EXTERN_C +/** Let the plugin symbols be always exported as C functions */ +#ifdef __cplusplus +#define MRCP_PLUGIN_EXTERN_C extern "C" +#else +#define MRCP_PLUGIN_EXTERN_C extern +#endif + /** Plugin export defines */ #ifdef WIN32 -#define MRCP_PLUGIN_DECLARE(type) EXTERN_C __declspec(dllexport) type +#define MRCP_PLUGIN_DECLARE(type) MRCP_PLUGIN_EXTERN_C __declspec(dllexport) type #else -#define MRCP_PLUGIN_DECLARE(type) type +#define MRCP_PLUGIN_DECLARE(type) MRCP_PLUGIN_EXTERN_C type #endif /** [REQUIRED] Symbol name of the main entry point in plugin DSO */ @@ -57,7 +64,8 @@ typedef apt_bool_t (*mrcp_plugin_log_accessor_f)(apt_logger_t *logger); /** Declare this macro in plugins to set plugin version */ #define MRCP_PLUGIN_VERSION_DECLARE \ - MRCP_PLUGIN_DECLARE(mrcp_plugin_version_t) mrcp_plugin_version = \ + MRCP_PLUGIN_DECLARE(mrcp_plugin_version_t) mrcp_plugin_version; \ + mrcp_plugin_version_t mrcp_plugin_version = \ {PLUGIN_MAJOR_VERSION, PLUGIN_MINOR_VERSION, PLUGIN_PATCH_VERSION}; @@ -72,7 +80,7 @@ typedef apt_bool_t (*mrcp_plugin_log_accessor_f)(apt_logger_t *logger); * Minor API changes that do not cause binary compatibility problems. * Reset to 0 when upgrading PLUGIN_MAJOR_VERSION */ -#define PLUGIN_MINOR_VERSION 0 +#define PLUGIN_MINOR_VERSION 2 /** patch level * The Patch Level never includes API changes, simply bug fixes. diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_types.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_types.h index 2187d19829..ee2390c255 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_types.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_engine_types.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: mrcp_engine_types.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_engine_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_ENGINE_TYPES_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_engine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_engine.h index 7a79f7e536..d9fce1bd97 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_engine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_engine.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: mrcp_recog_engine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recog_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECOG_ENGINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_state_machine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_state_machine.h index f03ebf13de..9be07b6bec 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_state_machine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recog_state_machine.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: mrcp_recog_state_machine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recog_state_machine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECOG_STATE_MACHINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_engine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_engine.h index 9c2c239145..90fa022725 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_engine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_engine.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: mrcp_recorder_engine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recorder_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECORDER_ENGINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_state_machine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_state_machine.h index 2c2f19bb58..242440a42f 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_state_machine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_recorder_state_machine.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: mrcp_recorder_state_machine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recorder_state_machine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECORDER_STATE_MACHINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_resource_engine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_resource_engine.h index 650e47a9e1..3743af9ab0 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_resource_engine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_resource_engine.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: mrcp_resource_engine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_resource_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RESOURCE_ENGINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_state_machine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_state_machine.h index a34a280443..acec6fa8bc 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_state_machine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_state_machine.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: mrcp_state_machine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_state_machine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_STATE_MACHINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_engine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_engine.h index 8cdc18dcef..0536ef4b4b 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_engine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_engine.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: mrcp_synth_engine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_synth_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SYNTH_ENGINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_state_machine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_state_machine.h index 08ae5716c1..2ddc1ac069 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_state_machine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_synth_state_machine.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: mrcp_synth_state_machine.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_synth_state_machine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SYNTH_STATE_MACHINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_engine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_engine.h index 20e4de31f1..e741209c27 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_engine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_engine.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: mrcp_verifier_engine.h 1755 2010-08-18 19:35:08Z achaloyan $ + * $Id: mrcp_verifier_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_VERIFIER_ENGINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_state_machine.h b/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_state_machine.h index a3b5e8e2b4..a4b320a87d 100644 --- a/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_state_machine.h +++ b/libs/unimrcp/libs/mrcp-engine/include/mrcp_verifier_state_machine.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: mrcp_verifier_state_machine.h 1755 2010-08-18 19:35:08Z achaloyan $ + * $Id: mrcp_verifier_state_machine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_VERIFIER_STATE_MACHINE_H diff --git a/libs/unimrcp/libs/mrcp-engine/mrcpengine.2008.vcproj b/libs/unimrcp/libs/mrcp-engine/mrcpengine.2008.vcproj deleted file mode 100644 index 6321572199..0000000000 --- a/libs/unimrcp/libs/mrcp-engine/mrcpengine.2008.vcproj +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj b/libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj new file mode 100644 index 0000000000..fcf2be3d80 --- /dev/null +++ b/libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj @@ -0,0 +1,142 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} + mrcpengine + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + X64 + + + ProgramDatabase + + + + + X64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b5a00bfa-6083-4fae-a097-71642d6473b5} + false + + + {1c320193-46a6-4b34-9c56-8ab584fc1b56} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj.filters b/libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj.filters new file mode 100644 index 0000000000..33be90e794 --- /dev/null +++ b/libs/unimrcp/libs/mrcp-engine/mrcpengine.vcxproj.filters @@ -0,0 +1,89 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {dd062ad2-9a06-4efc-8e17-328567b52854} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_factory.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_factory.c index 8de989af0a..5c20286fff 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_factory.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_factory.c @@ -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: mrcp_engine_factory.c 1761 2010-08-20 17:35:28Z achaloyan $ + * $Id: mrcp_engine_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_iface.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_iface.c index e8f45a4f98..daea6039c8 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_iface.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_iface.c @@ -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: mrcp_engine_iface.c 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_engine_iface.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_engine_iface.h" @@ -70,6 +70,8 @@ mrcp_engine_channel_t* mrcp_engine_channel_virtual_create(mrcp_engine_t *engine, return NULL; } if(engine->config->max_channel_count && engine->cur_channel_count >= engine->config->max_channel_count) { + apt_log(APT_LOG_MARK, APT_PRIO_NOTICE, "Maximum channel count %"APR_SIZE_T_FMT" exceeded for engine [%s]", + engine->config->max_channel_count, engine->id); return NULL; } channel = engine->method_vtable->create_channel(engine,pool); diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_impl.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_impl.c index 969dee4675..2e536e18b4 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_impl.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_impl.c @@ -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: mrcp_engine_impl.c 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_engine_impl.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_engine_impl.h" diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_loader.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_loader.c index da29170d65..45996cce7e 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_loader.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_engine_loader.c @@ -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: mrcp_engine_loader.c 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_engine_loader.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -160,6 +160,7 @@ MRCP_DECLARE(mrcp_engine_t*) mrcp_engine_loader_plugin_load(mrcp_engine_loader_t engine = plugin_creator(loader->pool); if(!engine) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create MRCP Engine"); + return NULL; } engine->id = id; diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_recog_state_machine.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_recog_state_machine.c index 50ddb972cb..f205d2ea78 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_recog_state_machine.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_recog_state_machine.c @@ -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: mrcp_recog_state_machine.c 1782 2010-09-06 17:52:41Z achaloyan $ + * $Id: mrcp_recog_state_machine.c 2228 2014-11-12 01:18:27Z achaloyan@gmail.com $ */ #include "apt_obj_list.h" @@ -116,8 +116,7 @@ static apt_bool_t recog_request_get_params(mrcp_recog_state_machine_t *state_mac static apt_bool_t recog_response_get_params(mrcp_recog_state_machine_t *state_machine, mrcp_message_t *message) { - mrcp_header_fields_set(&message->header,&state_machine->active_request->header,message->pool); - mrcp_header_fields_get(&message->header,state_machine->properties,message->pool); + mrcp_header_fields_get(&message->header,state_machine->properties,&state_machine->active_request->header,message->pool); return recog_response_dispatch(state_machine,message); } @@ -235,7 +234,7 @@ static apt_bool_t recog_pending_requests_remove(mrcp_recog_state_machine_t *stat mrcp_generic_header_t *generic_header = mrcp_generic_header_get(request_message); mrcp_generic_header_t *response_generic_header = mrcp_generic_header_prepare(response_message); if(generic_header && mrcp_generic_header_property_check(request_message,GENERIC_HEADER_ACTIVE_REQUEST_ID_LIST) == TRUE) { - if(generic_header->active_request_id_list.ids && generic_header->active_request_id_list.count) { + if(generic_header->active_request_id_list.count) { /* selective STOP request */ request_id_list = &generic_header->active_request_id_list; } @@ -270,7 +269,7 @@ static apt_bool_t recog_request_stop(mrcp_recog_state_machine_t *state_machine, mrcp_request_id_list_t *request_id_list = NULL; mrcp_generic_header_t *generic_header = mrcp_generic_header_get(message); if(generic_header && mrcp_generic_header_property_check(message,GENERIC_HEADER_ACTIVE_REQUEST_ID_LIST) == TRUE) { - if(generic_header->active_request_id_list.ids && generic_header->active_request_id_list.count) { + if(generic_header->active_request_id_list.count) { /* selective STOP request */ request_id_list = &generic_header->active_request_id_list; } diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_recorder_state_machine.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_recorder_state_machine.c index 312b4d57c3..ad7bd7b1b6 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_recorder_state_machine.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_recorder_state_machine.c @@ -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: mrcp_recorder_state_machine.c 1705 2010-05-23 14:04:20Z achaloyan $ + * $Id: mrcp_recorder_state_machine.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_obj_list.h" @@ -110,8 +110,7 @@ static apt_bool_t recorder_request_get_params(mrcp_recorder_state_machine_t *sta static apt_bool_t recorder_response_get_params(mrcp_recorder_state_machine_t *state_machine, mrcp_message_t *message) { - mrcp_header_fields_set(&message->header,&state_machine->active_request->header,message->pool); - mrcp_header_fields_get(&message->header,state_machine->properties,message->pool); + mrcp_header_fields_get(&message->header,state_machine->properties,&state_machine->active_request->header,message->pool); return recorder_response_dispatch(state_machine,message); } diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_synth_state_machine.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_synth_state_machine.c index 523fbd3fbc..205f39c0bf 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_synth_state_machine.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_synth_state_machine.c @@ -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: mrcp_synth_state_machine.c 1705 2010-05-23 14:04:20Z achaloyan $ + * $Id: mrcp_synth_state_machine.c 2228 2014-11-12 01:18:27Z achaloyan@gmail.com $ */ #include "apt_obj_list.h" @@ -116,8 +116,7 @@ static apt_bool_t synth_request_get_params(mrcp_synth_state_machine_t *state_mac static apt_bool_t synth_response_get_params(mrcp_synth_state_machine_t *state_machine, mrcp_message_t *message) { - mrcp_header_fields_set(&message->header,&state_machine->active_request->header,message->pool); - mrcp_header_fields_get(&message->header,state_machine->properties,message->pool); + mrcp_header_fields_get(&message->header,state_machine->properties,&state_machine->active_request->header,message->pool); return synth_response_dispatch(state_machine,message); } @@ -167,7 +166,7 @@ static apt_bool_t synth_pending_requests_remove(mrcp_synth_state_machine_t *stat mrcp_generic_header_t *generic_header = mrcp_generic_header_get(request_message); mrcp_generic_header_t *response_generic_header = mrcp_generic_header_prepare(response_message); if(generic_header && mrcp_generic_header_property_check(request_message,GENERIC_HEADER_ACTIVE_REQUEST_ID_LIST) == TRUE) { - if(generic_header->active_request_id_list.ids && generic_header->active_request_id_list.count) { + if(generic_header->active_request_id_list.count) { /* selective STOP request */ request_id_list = &generic_header->active_request_id_list; } @@ -202,7 +201,7 @@ static apt_bool_t synth_request_stop(mrcp_synth_state_machine_t *state_machine, mrcp_request_id_list_t *request_id_list = NULL; mrcp_generic_header_t *generic_header = mrcp_generic_header_get(message); if(generic_header && mrcp_generic_header_property_check(message,GENERIC_HEADER_ACTIVE_REQUEST_ID_LIST) == TRUE) { - if(generic_header->active_request_id_list.ids && generic_header->active_request_id_list.count) { + if(generic_header->active_request_id_list.count) { /* selective STOP request */ request_id_list = &generic_header->active_request_id_list; } diff --git a/libs/unimrcp/libs/mrcp-engine/src/mrcp_verifier_state_machine.c b/libs/unimrcp/libs/mrcp-engine/src/mrcp_verifier_state_machine.c index 335fdc9758..6ca313e51c 100644 --- a/libs/unimrcp/libs/mrcp-engine/src/mrcp_verifier_state_machine.c +++ b/libs/unimrcp/libs/mrcp-engine/src/mrcp_verifier_state_machine.c @@ -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: mrcp_verifier_state_machine.c 1756 2010-08-19 19:02:39Z achaloyan $ + * $Id: mrcp_verifier_state_machine.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_obj_list.h" @@ -112,8 +112,7 @@ static apt_bool_t verifier_request_get_params(mrcp_verifier_state_machine_t *sta static apt_bool_t verifier_response_get_params(mrcp_verifier_state_machine_t *state_machine, mrcp_message_t *message) { - mrcp_header_fields_set(&message->header,&state_machine->active_request->header,message->pool); - mrcp_header_fields_get(&message->header,state_machine->properties,message->pool); + mrcp_header_fields_get(&message->header,state_machine->properties,&state_machine->active_request->header,message->pool); return verifier_response_dispatch(state_machine,message); } diff --git a/libs/unimrcp/libs/mrcp-server/Makefile.am b/libs/unimrcp/libs/mrcp-server/Makefile.am index 14a90285ca..0ebf90cab0 100644 --- a/libs/unimrcp/libs/mrcp-server/Makefile.am +++ b/libs/unimrcp/libs/mrcp-server/Makefile.am @@ -1,4 +1,4 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-server/include \ -I$(top_srcdir)/libs/mrcp-engine/include \ @@ -10,7 +10,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-server/include \ -I$(top_srcdir)/libs/mrcp/resources/include \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmrcpserver.la diff --git a/libs/unimrcp/libs/mrcp-server/include/mrcp_server.h b/libs/unimrcp/libs/mrcp-server/include/mrcp_server.h index f2bf49fe37..0f3232fcc4 100644 --- a/libs/unimrcp/libs/mrcp-server/include/mrcp_server.h +++ b/libs/unimrcp/libs/mrcp-server/include/mrcp_server.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: mrcp_server.h 1721 2010-06-01 05:45:46Z achaloyan $ + * $Id: mrcp_server.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SERVER_H @@ -140,6 +140,7 @@ MRCP_DECLARE(apt_bool_t) mrcp_server_connection_agent_register( /** Create MRCP profile */ MRCP_DECLARE(mrcp_profile_t*) mrcp_server_profile_create( const char *id, + mrcp_version_e mrcp_version, mrcp_resource_factory_t *resource_factory, mrcp_sig_agent_t *signaling_agent, mrcp_connection_agent_t *connection_agent, diff --git a/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h b/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h index 07258f0298..61ea0c8141 100644 --- a/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h +++ b/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.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: mrcp_server_session.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_server_session.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SERVER_SESSION_H @@ -113,6 +113,8 @@ struct mrcp_server_session_t { struct mrcp_profile_t { /** Identifier of the profile */ const char *id; + /** MRCP version */ + mrcp_version_e mrcp_version; /** Table of engines (mrcp_engine_t*) */ apr_hash_t *engine_table; /** MRCP resource factory */ diff --git a/libs/unimrcp/libs/mrcp-server/include/mrcp_server_types.h b/libs/unimrcp/libs/mrcp-server/include/mrcp_server_types.h index 2c9f3f0be8..a301921df4 100644 --- a/libs/unimrcp/libs/mrcp-server/include/mrcp_server_types.h +++ b/libs/unimrcp/libs/mrcp-server/include/mrcp_server_types.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: mrcp_server_types.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_server_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SERVER_TYPES_H diff --git a/libs/unimrcp/libs/mrcp-server/mrcpserver.2008.vcproj b/libs/unimrcp/libs/mrcp-server/mrcpserver.2008.vcproj deleted file mode 100644 index fe124d4a8a..0000000000 --- a/libs/unimrcp/libs/mrcp-server/mrcpserver.2008.vcproj +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj b/libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj new file mode 100644 index 0000000000..2c09de002a --- /dev/null +++ b/libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj @@ -0,0 +1,127 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {18B1F35A-10F8-4287-9B37-2D10501B0B38} + mrcpserver + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + X64 + + + ProgramDatabase + + + + + X64 + + + + + + + + + + + + + + {843425be-9a9a-44f4-a4e3-4b57d6abd53c} + false + + + {12a49562-bab9-43a3-a21d-15b60bbb4c31} + false + + + {a9edac04-6a5f-4ba7-bc0d-cce7b255b6ea} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj.filters b/libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj.filters similarity index 61% rename from libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj.filters rename to libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj.filters index d2157eea88..866a6dfbbc 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj.filters +++ b/libs/unimrcp/libs/mrcp-server/mrcpserver.vcxproj.filters @@ -1,35 +1,32 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {6e92b598-880e-4fe5-88fb-f69df8e06a57} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - - - src - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4557fd27-79b0-442d-809b-82996c7da820} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c b/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c index bd1b6aa848..3fff2b77d7 100644 --- a/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c +++ b/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c @@ -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: mrcp_server.c 1721 2010-06-01 05:45:46Z achaloyan $ + * $Id: mrcp_server.c 2178 2014-09-13 02:36:05Z achaloyan@gmail.com $ */ #include "mrcp_server.h" @@ -25,7 +25,7 @@ #include "mrcp_engine_loader.h" #include "mrcp_sig_agent.h" #include "mrcp_server_connection.h" -#include "mpf_engine.h" +#include "mpf_termination_factory.h" #include "apt_pool.h" #include "apt_consumer_task.h" #include "apt_obj_list.h" @@ -92,7 +92,8 @@ static apt_bool_t mrcp_server_control_signal(mrcp_session_t *session, mrcp_messa static const mrcp_session_request_vtable_t session_request_vtable = { mrcp_server_offer_signal, mrcp_server_terminate_signal, - mrcp_server_control_signal + mrcp_server_control_signal, + NULL /* mrcp_server_discover_signal */ }; @@ -164,11 +165,11 @@ const mrcp_engine_channel_event_vtable_t engine_channel_vtable = { }; /* Task interface */ -static void mrcp_server_on_start_request(apt_task_t *task); -static void mrcp_server_on_terminate_request(apt_task_t *task); +static apt_bool_t mrcp_server_msg_process(apt_task_t *task, apt_task_msg_t *msg); +static apt_bool_t mrcp_server_start_request_process(apt_task_t *task); +static apt_bool_t mrcp_server_terminate_request_process(apt_task_t *task); static void mrcp_server_on_start_complete(apt_task_t *task); static void mrcp_server_on_terminate_complete(apt_task_t *task); -static apt_bool_t mrcp_server_msg_process(apt_task_t *task, apt_task_msg_t *msg); static mrcp_session_t* mrcp_server_sig_agent_session_create(mrcp_sig_agent_t *signaling_agent); @@ -216,8 +217,8 @@ MRCP_DECLARE(mrcp_server_t*) mrcp_server_create(apt_dir_layout_t *dir_layout) vtable = apt_task_vtable_get(task); if(vtable) { vtable->process_msg = mrcp_server_msg_process; - vtable->on_start_request = mrcp_server_on_start_request; - vtable->on_terminate_request = mrcp_server_on_terminate_request; + vtable->process_start = mrcp_server_start_request_process; + vtable->process_terminate = mrcp_server_terminate_request_process; vtable->on_start_complete = mrcp_server_on_start_complete; vtable->on_terminate_complete = mrcp_server_on_terminate_complete; } @@ -460,6 +461,7 @@ MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_server_connection_agent_get(const mr /** Create MRCP profile */ MRCP_DECLARE(mrcp_profile_t*) mrcp_server_profile_create( const char *id, + mrcp_version_e mrcp_version, mrcp_resource_factory_t *resource_factory, mrcp_sig_agent_t *signaling_agent, mrcp_connection_agent_t *connection_agent, @@ -470,6 +472,7 @@ MRCP_DECLARE(mrcp_profile_t*) mrcp_server_profile_create( { mrcp_profile_t *profile = apr_palloc(pool,sizeof(mrcp_profile_t)); profile->id = id; + profile->mrcp_version = mrcp_version; profile->resource_factory = resource_factory; profile->engine_table = NULL; profile->media_engine = media_engine; @@ -477,6 +480,8 @@ MRCP_DECLARE(mrcp_profile_t*) mrcp_server_profile_create( profile->rtp_settings = rtp_settings; profile->signaling_agent = signaling_agent; profile->connection_agent = connection_agent; + + mpf_termination_factory_engine_assign(rtp_factory,media_engine); return profile; } @@ -543,7 +548,7 @@ MRCP_DECLARE(apt_bool_t) mrcp_server_profile_register( apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing signaling agent",profile->id); return FALSE; } - if(profile->signaling_agent->mrcp_version == MRCP_VERSION_2 && + if(profile->mrcp_version == MRCP_VERSION_2 && !profile->connection_agent) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Profile [%s]: missing connection agent",profile->id); return FALSE; @@ -614,7 +619,7 @@ static APR_INLINE mrcp_server_session_t* mrcp_server_session_find(mrcp_server_t return apr_hash_get(server->session_table,session_id->buf,session_id->length); } -static void mrcp_server_on_start_request(apt_task_t *task) +static apt_bool_t mrcp_server_start_request_process(apt_task_t *task) { apt_consumer_task_t *consumer_task = apt_task_object_get(task); mrcp_server_t *server = apt_consumer_task_object_get(consumer_task); @@ -632,9 +637,11 @@ static void mrcp_server_on_start_request(apt_task_t *task) } } } + + return apt_task_start_request_process(task); } -static void mrcp_server_on_terminate_request(apt_task_t *task) +static apt_bool_t mrcp_server_terminate_request_process(apt_task_t *task) { apt_consumer_task_t *consumer_task = apt_task_object_get(task); mrcp_server_t *server = apt_consumer_task_object_get(consumer_task); @@ -652,6 +659,8 @@ static void mrcp_server_on_terminate_request(apt_task_t *task) } } } + + return apt_task_terminate_request_process(task); } static void mrcp_server_on_start_complete(apt_task_t *task) diff --git a/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c b/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c index 9a18b9ae14..c2dfb0b98f 100644 --- a/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c +++ b/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c @@ -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: mrcp_server_session.c 1794 2011-01-20 18:59:01Z achaloyan $ + * $Id: mrcp_server_session.c 2237 2014-11-12 01:48:46Z achaloyan@gmail.com $ */ #include "mrcp_server.h" @@ -118,7 +118,7 @@ mrcp_server_session_t* mrcp_server_session_create() static APR_INLINE mrcp_version_e mrcp_session_version_get(mrcp_server_session_t *session) { - return session->base.signaling_agent->mrcp_version; + return session->profile->mrcp_version; } static mrcp_engine_channel_t* mrcp_server_engine_channel_create( @@ -504,7 +504,7 @@ static apt_bool_t mrcp_server_session_terminate_process(mrcp_server_session_t *s for(i=0; iterminations->nelts; i++) { /* get existing termination */ slot = &APR_ARRAY_IDX(session->terminations,i,mrcp_termination_slot_t); - if(!slot || !slot->termination) continue; + if(!slot->termination) continue; /* send subtract termination request */ apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Subtract Media Termination "APT_NAMESIDRES_FMT, @@ -568,7 +568,7 @@ static apt_bool_t mrcp_server_on_message_receive(mrcp_server_session_t *session, if(!channel->resource || !channel->state_machine) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Resource "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), - channel->resource->name.buf); + message->channel_id.resource_name.buf); return FALSE; } @@ -737,7 +737,7 @@ static apt_bool_t mrcp_server_control_media_offer_process(mrcp_server_session_t /* create new MRCP channel instance */ channel = mrcp_server_channel_create(session,&control_descriptor->resource_name,i,control_descriptor->cmid_arr); - if(!channel) continue; + if(!channel || !channel->resource) continue; control_descriptor->session_id = session->base.id; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Add Control Channel "APT_NAMESIDRES_FMT" [%d]", @@ -827,8 +827,17 @@ static mpf_rtp_termination_descriptor_t* mrcp_server_associations_build(mrcp_ser } if(mrcp_session_version_get(session) == MRCP_VERSION_1) { - /* implicitly modify the descriptor, if needed */ mpf_stream_direction_e direction = audio_stream->direction; + /* implicitly modify the descriptor, if needed */ + if(media_descriptor->direction == STREAM_DIRECTION_NONE && mpf_codec_list_is_empty(&media_descriptor->codec_list) == TRUE) { + /* this is the case when SETUP contains no SDP, assume all the available codecs are offered */ + if(mpf_codec_list_is_empty(&session->profile->rtp_settings->codec_list) == FALSE) { + mpf_codec_list_copy(&media_descriptor->codec_list, + &session->profile->rtp_settings->codec_list, + session->base.pool); + } + } + media_descriptor->direction |= direction; if(media_descriptor->state == MPF_MEDIA_DISABLED) { media_descriptor->state = MPF_MEDIA_ENABLED; @@ -881,7 +890,7 @@ static apt_bool_t mrcp_server_av_media_offer_process(mrcp_server_session_t *sess for(i=0; iterminations,i,mrcp_termination_slot_t); - if(!slot || !slot->termination) continue; + if(!slot->termination) continue; /* build associations between specified RTP termination and control channels */ rtp_descriptor = mrcp_server_associations_build(session,descriptor,slot); @@ -990,7 +999,7 @@ static mrcp_termination_slot_t* mrcp_server_rtp_termination_find(mrcp_server_ses mrcp_termination_slot_t *slot; for(i=0; iterminations->nelts; i++) { slot = &APR_ARRAY_IDX(session->terminations,i,mrcp_termination_slot_t); - if(slot && slot->termination == termination) { + if(slot->termination == termination) { return slot; } } @@ -1030,9 +1039,6 @@ static mrcp_channel_t* mrcp_server_channel_find(mrcp_server_session_t *session, static apt_bool_t mrcp_server_on_termination_modify(mrcp_server_session_t *session, const mpf_message_t *mpf_message) { mrcp_termination_slot_t *termination_slot; - if(!session) { - return FALSE; - } apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Media Termination Modified "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); @@ -1066,9 +1072,6 @@ static apt_bool_t mrcp_server_on_termination_modify(mrcp_server_session_t *sessi static apt_bool_t mrcp_server_on_termination_subtract(mrcp_server_session_t *session, const mpf_message_t *mpf_message) { mrcp_termination_slot_t *termination_slot; - if(!session) { - return FALSE; - } apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Media Termination Subtracted "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); @@ -1105,7 +1108,10 @@ apt_bool_t mrcp_server_mpf_message_process(mpf_message_container_t *mpf_message_ else { session = NULL; } - + if(!session) { + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Received MPF Message: NULL session"); + continue; + } if(mpf_message->message_type == MPF_MESSAGE_TYPE_RESPONSE) { switch(mpf_message->command_id) { case MPF_ADD_TERMINATION: diff --git a/libs/unimrcp/libs/mrcp-signaling/Makefile.am b/libs/unimrcp/libs/mrcp-signaling/Makefile.am index 0ce6432740..e274f1ce83 100644 --- a/libs/unimrcp/libs/mrcp-signaling/Makefile.am +++ b/libs/unimrcp/libs/mrcp-signaling/Makefile.am @@ -1,10 +1,10 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp-signaling/include \ -I$(top_srcdir)/libs/mrcp/include \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmrcpsignaling.la @@ -14,4 +14,4 @@ include_HEADERS = include/mrcp_sig_types.h \ include/mrcp_session_descriptor.h libmrcpsignaling_la_SOURCES = src/mrcp_sig_agent.c \ - src/mrcp_session_descriptor.c + src/mrcp_session_descriptor.c \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session.h b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session.h index b1f2ead512..f4b9ebcc96 100644 --- a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session.h +++ b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session.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: mrcp_session.h 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_session.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SESSION_H @@ -25,6 +25,7 @@ */ #include "mrcp_sig_types.h" +#include "mpf_types.h" #include "apt_string.h" APT_BEGIN_EXTERN_C @@ -57,8 +58,15 @@ struct mrcp_session_t { void *log_obj; /** Informative name of the session used for debugging */ const char *name; - /** Back pointer to signaling agent */ - mrcp_sig_agent_t *signaling_agent; + + /** Signaling (session managment) agent */ + mrcp_sig_agent_t *signaling_agent; + /** MRCPv2 connection agent, if any */ + void *connection_agent; + /** Media processing engine */ + mpf_engine_t *media_engine; + /** RTP termination factory */ + mpf_termination_factory_t *rtp_factory; /** Session identifier */ apt_str_t id; diff --git a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session_descriptor.h b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session_descriptor.h index 9cdbbc9dfe..e1e9b48448 100644 --- a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session_descriptor.h +++ b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_session_descriptor.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: mrcp_session_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_session_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SESSION_DESCRIPTOR_H @@ -31,11 +31,11 @@ APT_BEGIN_EXTERN_C /** MRCP session status */ typedef enum { - MRCP_SESSION_STATUS_OK, /**< OK */ + MRCP_SESSION_STATUS_OK, /**< OK */ MRCP_SESSION_STATUS_NO_SUCH_RESOURCE, /**< no such resource found */ MRCP_SESSION_STATUS_UNACCEPTABLE_RESOURCE,/**< resource exists, but no implementation (plugin) found */ MRCP_SESSION_STATUS_UNAVAILABLE_RESOURCE, /**< resource exists, but is temporary unavailable */ - MRCP_SESSION_STATUS_ERROR /**< internal error occuried */ + MRCP_SESSION_STATUS_ERROR /**< internal error occurred */ } mrcp_session_status_e; /** MRCP session descriptor */ @@ -52,6 +52,8 @@ struct mrcp_session_descriptor_t { apt_bool_t resource_state; /** Session status */ mrcp_session_status_e status; + /** Response code (SIP for MRCPv2 and RTSP for MRCPv1) */ + int response_code; /** MRCP control media array (mrcp_control_descriptor_t) */ apr_array_header_t *control_media_arr; diff --git a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_agent.h b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_agent.h index a0ef308470..6acc24621f 100644 --- a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_agent.h +++ b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_agent.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: mrcp_sig_agent.h 1750 2010-07-23 19:33:34Z achaloyan $ + * $Id: mrcp_sig_agent.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SIG_AGENT_H @@ -50,8 +50,6 @@ struct mrcp_sig_settings_t { char *feature_tags; }; - - /** MRCP signaling agent */ struct mrcp_sig_agent_t { /** Agent identifier */ @@ -62,8 +60,6 @@ struct mrcp_sig_agent_t { void *obj; /** Parent object (client/server) */ void *parent; - /** MRCP version */ - mrcp_version_e mrcp_version; /** MRCP resource factory */ mrcp_resource_factory_t *resource_factory; /** Task interface */ @@ -78,7 +74,19 @@ struct mrcp_sig_agent_t { }; /** Create signaling agent. */ -MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_signaling_agent_create(const char *id, void *obj, mrcp_version_e mrcp_version, apr_pool_t *pool); +MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_signaling_agent_create(const char *id, void *obj, apr_pool_t *pool); + +/** Create factory of signaling agents. */ +MRCP_DECLARE(mrcp_sa_factory_t*) mrcp_sa_factory_create(apr_pool_t *pool); + +/** Add signaling agent to factory. */ +MRCP_DECLARE(apt_bool_t) mrcp_sa_factory_agent_add(mrcp_sa_factory_t *sa_factory, mrcp_sig_agent_t *sig_agent); + +/** Determine whether factory is empty. */ +MRCP_DECLARE(apt_bool_t) mrcp_sa_factory_is_empty(const mrcp_sa_factory_t *sa_factory); + +/** Select next available signaling agent. */ +MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sa_factory_agent_select(mrcp_sa_factory_t *sa_factory); /** Allocate MRCP signaling settings. */ MRCP_DECLARE(mrcp_sig_settings_t*) mrcp_signaling_settings_alloc(apr_pool_t *pool); diff --git a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_types.h b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_types.h index c45b4be6e6..6dc589036e 100644 --- a/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_types.h +++ b/libs/unimrcp/libs/mrcp-signaling/include/mrcp_sig_types.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: mrcp_sig_types.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_sig_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SIG_TYPES_H @@ -34,6 +34,9 @@ typedef struct mrcp_sig_settings_t mrcp_sig_settings_t; /** Opaque MRCP signaling agent declaration */ typedef struct mrcp_sig_agent_t mrcp_sig_agent_t; +/** Opaque MRCP signaling agent factory declaration */ +typedef struct mrcp_sa_factory_t mrcp_sa_factory_t; + /** Opaque MRCP session declaration */ typedef struct mrcp_session_t mrcp_session_t; diff --git a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2008.vcproj b/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2008.vcproj deleted file mode 100644 index 25e0f23d9c..0000000000 --- a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2008.vcproj +++ /dev/null @@ -1,289 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2010.vcxproj b/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.vcxproj similarity index 64% rename from libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2010.vcxproj rename to libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.vcxproj index f11e3bd765..b37946889a 100644 --- a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2010.vcxproj +++ b/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.vcxproj @@ -1,121 +1,124 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpsignaling - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} - mrcpsignaling - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {12A49562-BAB9-43A3-A21D-15B60BBB4C31} + mrcpsignaling + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + X64 + + + ProgramDatabase + + + + + X64 + + + + + + + + + + + + + + + {b5a00bfa-6083-4fae-a097-71642d6473b5} + false + + + {1c320193-46a6-4b34-9c56-8ab584fc1b56} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2010.vcxproj.filters b/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.vcxproj.filters similarity index 91% rename from libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2010.vcxproj.filters rename to libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.vcxproj.filters index 4e5d30c3da..7b9d1aa49b 100644 --- a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2010.vcxproj.filters +++ b/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.vcxproj.filters @@ -1,35 +1,35 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {f3dc550f-1a0f-4b9e-b077-3b6940dc5531} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - include - - - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {38ec7b90-673c-4c54-9c3a-13d5270556a0} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + include + + + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp-signaling/src/mrcp_session_descriptor.c b/libs/unimrcp/libs/mrcp-signaling/src/mrcp_session_descriptor.c index 54d89ff258..a14545708b 100644 --- a/libs/unimrcp/libs/mrcp-signaling/src/mrcp_session_descriptor.c +++ b/libs/unimrcp/libs/mrcp-signaling/src/mrcp_session_descriptor.c @@ -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: mrcp_session_descriptor.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_session_descriptor.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_session_descriptor.h" @@ -27,6 +27,7 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_session_descriptor_create(apr_pool apt_string_reset(&descriptor->resource_name); descriptor->resource_state = FALSE; descriptor->status = MRCP_SESSION_STATUS_OK; + descriptor->response_code = 0; descriptor->control_media_arr = apr_array_make(pool,1,sizeof(void*)); descriptor->audio_media_arr = apr_array_make(pool,1,sizeof(mpf_rtp_media_descriptor_t*)); descriptor->video_media_arr = apr_array_make(pool,0,sizeof(mpf_rtp_media_descriptor_t*)); diff --git a/libs/unimrcp/libs/mrcp-signaling/src/mrcp_sig_agent.c b/libs/unimrcp/libs/mrcp-signaling/src/mrcp_sig_agent.c index ba8570a606..dca8de94c3 100644 --- a/libs/unimrcp/libs/mrcp-signaling/src/mrcp_sig_agent.c +++ b/libs/unimrcp/libs/mrcp-signaling/src/mrcp_sig_agent.c @@ -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,20 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mrcp_sig_agent.c 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_sig_agent.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_sig_agent.h" #include "mrcp_session.h" #include "apt_pool.h" -MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_signaling_agent_create(const char *id, void *obj, mrcp_version_e mrcp_version, apr_pool_t *pool) +/** Factory of MRCP signaling agents */ +struct mrcp_sa_factory_t { + /** Array of pointers to signaling agents */ + apr_array_header_t *agents_arr; + /** Index of the current agent */ + int index; +}; + +/** Create signaling agent */ +MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_signaling_agent_create(const char *id, void *obj, apr_pool_t *pool) { mrcp_sig_agent_t *sig_agent = apr_palloc(pool,sizeof(mrcp_sig_agent_t)); sig_agent->id = id; sig_agent->pool = pool; sig_agent->obj = obj; - sig_agent->mrcp_version = mrcp_version; sig_agent->resource_factory = NULL; sig_agent->parent = NULL; sig_agent->task = NULL; @@ -36,6 +44,43 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_signaling_agent_create(const char *id, void return sig_agent; } +/** Create factory of signaling agents */ +MRCP_DECLARE(mrcp_sa_factory_t*) mrcp_sa_factory_create(apr_pool_t *pool) +{ + mrcp_sa_factory_t *sa_factory = apr_palloc(pool,sizeof(mrcp_sa_factory_t)); + sa_factory->agents_arr = apr_array_make(pool,1,sizeof(mrcp_sig_agent_t*)); + sa_factory->index = 0; + return sa_factory; +} + +/** Add signaling agent to pool */ +MRCP_DECLARE(apt_bool_t) mrcp_sa_factory_agent_add(mrcp_sa_factory_t *sa_factory, mrcp_sig_agent_t *sig_agent) +{ + mrcp_sig_agent_t **slot; + if(!sig_agent) + return FALSE; + + slot = apr_array_push(sa_factory->agents_arr); + *slot = sig_agent; + return TRUE; +} + +/** Determine whether factory is empty. */ +MRCP_DECLARE(apt_bool_t) mrcp_sa_factory_is_empty(const mrcp_sa_factory_t *sa_factory) +{ + return apr_is_empty_array(sa_factory->agents_arr); +} + +/** Select next available signaling agent */ +MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sa_factory_agent_select(mrcp_sa_factory_t *sa_factory) +{ + mrcp_sig_agent_t *sig_agent = APR_ARRAY_IDX(sa_factory->agents_arr, sa_factory->index, mrcp_sig_agent_t*); + if(++sa_factory->index == sa_factory->agents_arr->nelts) { + sa_factory->index = 0; + } + return sig_agent; +} + /** Allocate MRCP signaling settings */ MRCP_DECLARE(mrcp_sig_settings_t*) mrcp_signaling_settings_alloc(apr_pool_t *pool) { @@ -64,6 +109,9 @@ MRCP_DECLARE(mrcp_session_t*) mrcp_session_create(apr_size_t padding) session->log_obj = NULL; session->name = NULL; session->signaling_agent = NULL; + session->connection_agent = NULL; + session->media_engine = NULL; + session->rtp_factory = NULL; session->request_vtable = NULL; session->response_vtable = NULL; session->event_vtable = NULL; diff --git a/libs/unimrcp/libs/mrcp/Makefile.am b/libs/unimrcp/libs/mrcp/Makefile.am index ade1e4408d..7c893f8dd9 100644 --- a/libs/unimrcp/libs/mrcp/Makefile.am +++ b/libs/unimrcp/libs/mrcp/Makefile.am @@ -1,11 +1,11 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp/include \ -I$(top_srcdir)/libs/mrcp/message/include \ -I$(top_srcdir)/libs/mrcp/control/include \ -I$(top_srcdir)/libs/mrcp/resources/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmrcp.la diff --git a/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h b/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h index 0f45fe54cc..9c2910903a 100644 --- a/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h +++ b/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.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: mrcp_resource.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_resource.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RESOURCE_H diff --git a/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_factory.h b/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_factory.h index 84631b13d7..0f3c2f6e09 100644 --- a/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_factory.h +++ b/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_factory.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: mrcp_resource_factory.h 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: mrcp_resource_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RESOURCE_FACTORY_H diff --git a/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_loader.h b/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_loader.h index a6608aba3b..555b580a6d 100644 --- a/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_loader.h +++ b/libs/unimrcp/libs/mrcp/control/include/mrcp_resource_loader.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: mrcp_resource_loader.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_resource_loader.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RESOURCE_LOADER_H diff --git a/libs/unimrcp/libs/mrcp/control/include/mrcp_stream.h b/libs/unimrcp/libs/mrcp/control/include/mrcp_stream.h index ab5c4c6fa5..1389effb42 100644 --- a/libs/unimrcp/libs/mrcp/control/include/mrcp_stream.h +++ b/libs/unimrcp/libs/mrcp/control/include/mrcp_stream.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: mrcp_stream.h 1660 2010-04-19 18:29:06Z achaloyan $ + * $Id: mrcp_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_STREAM_H diff --git a/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_factory.c b/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_factory.c index 21c6d341e6..e0a1124075 100644 --- a/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_factory.c +++ b/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_factory.c @@ -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: mrcp_resource_factory.c 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: mrcp_resource_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_loader.c b/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_loader.c index 2160b2a614..d172bdddb4 100644 --- a/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_loader.c +++ b/libs/unimrcp/libs/mrcp/control/src/mrcp_resource_loader.c @@ -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: mrcp_resource_loader.c 1764 2010-08-23 18:02:18Z achaloyan $ + * $Id: mrcp_resource_loader.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_resource_loader.h" diff --git a/libs/unimrcp/libs/mrcp/control/src/mrcp_stream.c b/libs/unimrcp/libs/mrcp/control/src/mrcp_stream.c index 94f067240c..7791764722 100644 --- a/libs/unimrcp/libs/mrcp/control/src/mrcp_stream.c +++ b/libs/unimrcp/libs/mrcp/control/src/mrcp_stream.c @@ -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: mrcp_stream.c 1671 2010-04-28 19:50:29Z achaloyan $ + * $Id: mrcp_stream.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_stream.h" diff --git a/libs/unimrcp/libs/mrcp/include/mrcp.h b/libs/unimrcp/libs/mrcp/include/mrcp.h index 9425954a78..995443e7ee 100644 --- a/libs/unimrcp/libs/mrcp/include/mrcp.h +++ b/libs/unimrcp/libs/mrcp/include/mrcp.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: mrcp.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_H diff --git a/libs/unimrcp/libs/mrcp/include/mrcp_types.h b/libs/unimrcp/libs/mrcp/include/mrcp_types.h index 7509f01888..3f37cb6cfe 100644 --- a/libs/unimrcp/libs/mrcp/include/mrcp_types.h +++ b/libs/unimrcp/libs/mrcp/include/mrcp_types.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: mrcp_types.h 1753 2010-08-16 20:46:45Z achaloyan $ + * $Id: mrcp_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_TYPES_H diff --git a/libs/unimrcp/libs/mrcp/message/include/mrcp_generic_header.h b/libs/unimrcp/libs/mrcp/message/include/mrcp_generic_header.h index 10b3d98917..af84350da4 100644 --- a/libs/unimrcp/libs/mrcp/message/include/mrcp_generic_header.h +++ b/libs/unimrcp/libs/mrcp/message/include/mrcp_generic_header.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: mrcp_generic_header.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_generic_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_GENERIC_HEADER_H diff --git a/libs/unimrcp/libs/mrcp/message/include/mrcp_header.h b/libs/unimrcp/libs/mrcp/message/include/mrcp_header.h index 91655864c9..9c9c0d5dee 100644 --- a/libs/unimrcp/libs/mrcp/message/include/mrcp_header.h +++ b/libs/unimrcp/libs/mrcp/message/include/mrcp_header.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: mrcp_header.h 1648 2010-04-12 20:03:59Z achaloyan $ + * $Id: mrcp_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_HEADER_H @@ -96,7 +96,7 @@ MRCP_DECLARE(apt_bool_t) mrcp_header_field_add(mrcp_message_header_t *header, ap MRCP_DECLARE(apt_bool_t) mrcp_header_fields_set(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, apr_pool_t *pool); /** Get (copy) MRCP header fields */ -MRCP_DECLARE(apt_bool_t) mrcp_header_fields_get(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, apr_pool_t *pool); +MRCP_DECLARE(apt_bool_t) mrcp_header_fields_get(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, const mrcp_message_header_t *mask_header, apr_pool_t *pool); /** Inherit (copy) MRCP header fields */ MRCP_DECLARE(apt_bool_t) mrcp_header_fields_inherit(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, apr_pool_t *pool); diff --git a/libs/unimrcp/libs/mrcp/message/include/mrcp_header_accessor.h b/libs/unimrcp/libs/mrcp/message/include/mrcp_header_accessor.h index e2c7590f0d..217b7bb2cd 100644 --- a/libs/unimrcp/libs/mrcp/message/include/mrcp_header_accessor.h +++ b/libs/unimrcp/libs/mrcp/message/include/mrcp_header_accessor.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: mrcp_header_accessor.h 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: mrcp_header_accessor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_HEADER_ACCESSOR_H diff --git a/libs/unimrcp/libs/mrcp/message/include/mrcp_message.h b/libs/unimrcp/libs/mrcp/message/include/mrcp_message.h index 3bfe453882..569a91b4bf 100644 --- a/libs/unimrcp/libs/mrcp/message/include/mrcp_message.h +++ b/libs/unimrcp/libs/mrcp/message/include/mrcp_message.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: mrcp_message.h 1721 2010-06-01 05:45:46Z achaloyan $ + * $Id: mrcp_message.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_MESSAGE_H diff --git a/libs/unimrcp/libs/mrcp/message/include/mrcp_start_line.h b/libs/unimrcp/libs/mrcp/message/include/mrcp_start_line.h index 0273229b75..8b739a259f 100644 --- a/libs/unimrcp/libs/mrcp/message/include/mrcp_start_line.h +++ b/libs/unimrcp/libs/mrcp/message/include/mrcp_start_line.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: mrcp_start_line.h 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: mrcp_start_line.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_START_LINE_H @@ -34,9 +34,9 @@ typedef enum { /** The request was processed to completion and there will be no more events from that resource to the client with that request-id */ MRCP_REQUEST_STATE_COMPLETE, - /** The job has been placed on a queue and will be processed in first-in-first-out order */ - MRCP_REQUEST_STATE_INPROGRESS, /** Indicate that further event messages will be delivered with that request-id */ + MRCP_REQUEST_STATE_INPROGRESS, + /** The job has been placed on a queue and will be processed in first-in-first-out order */ MRCP_REQUEST_STATE_PENDING, /** Number of request states */ diff --git a/libs/unimrcp/libs/mrcp/message/src/mrcp_generic_header.c b/libs/unimrcp/libs/mrcp/message/src/mrcp_generic_header.c index dc8878b446..858a76f802 100644 --- a/libs/unimrcp/libs/mrcp/message/src/mrcp_generic_header.c +++ b/libs/unimrcp/libs/mrcp/message/src/mrcp_generic_header.c @@ -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: mrcp_generic_header.c 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_generic_header.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_generic_header.h" @@ -58,20 +58,33 @@ static apt_bool_t mrcp_request_id_list_parse(mrcp_request_id_list_t *request_id_ } /** Generate mrcp request-id list */ -static apt_bool_t mrcp_request_id_list_generate(mrcp_request_id_list_t *request_id_list, apt_str_t *str, apr_pool_t *pool) +static apt_bool_t mrcp_request_id_list_generate(const mrcp_request_id_list_t *request_id_list, apt_str_t *str, apr_pool_t *pool) { apr_size_t i; - char buf[256]; - apt_text_stream_t stream; - apt_text_stream_init(&stream,buf,sizeof(buf)); - for(i=0; icount; i++) { - mrcp_request_id_generate(request_id_list->ids[i],&stream); - if(i < request_id_list->count-1) { - *stream.pos++ = ','; - } + int length; + char *pos; + + /* compute estimated length, assuming request-ids consist of upto 10 digits */ + str->length = 10 * request_id_list->count; + if(request_id_list->count > 1) { + /* , */ + str->length += request_id_list->count - 1; } - apt_string_assign_n(str,stream.text.buf, stream.pos - stream.text.buf, pool); + str->buf = apr_palloc(pool,str->length + 1); + + pos = str->buf; + for(i=0; icount; i++) { + if(i != 0) { + *pos++ = ','; + } + + length = apr_snprintf(pos, str->length - (pos - str->buf), "%"MRCP_REQUEST_ID_FMT, request_id_list->ids[i]); + if(length < 0) + return FALSE; + pos += length; + } + *pos = '\0'; return TRUE; } diff --git a/libs/unimrcp/libs/mrcp/message/src/mrcp_header.c b/libs/unimrcp/libs/mrcp/message/src/mrcp_header.c index 864baedc42..22d02692e1 100644 --- a/libs/unimrcp/libs/mrcp/message/src/mrcp_header.c +++ b/libs/unimrcp/libs/mrcp/message/src/mrcp_header.c @@ -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: mrcp_header.c 1737 2010-06-15 18:29:17Z achaloyan $ + * $Id: mrcp_header.c 2238 2014-11-12 01:50:43Z achaloyan@gmail.com $ */ #include "mrcp_header.h" @@ -74,7 +74,6 @@ MRCP_DECLARE(apt_bool_t) mrcp_header_field_add(mrcp_message_header_t *header, ap header_field->id += GENERIC_HEADER_COUNT; } else if(mrcp_header_field_value_parse(&header->generic_header_accessor,header_field,pool) == TRUE) { - status = apt_header_section_field_add(&header->header_section,header_field); } else { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Unknown MRCP header field: %s",header_field->name.buf); @@ -107,6 +106,30 @@ MRCP_DECLARE(apt_bool_t) mrcp_header_fields_parse(mrcp_message_header_t *header, return TRUE; } +static apt_bool_t mrcp_header_accessor_value_duplicate(mrcp_message_header_t *header, apt_header_field_t *header_field, + const mrcp_message_header_t *src_header, const apt_header_field_t *src_header_field, + apr_pool_t *pool) +{ + apt_bool_t status = FALSE; + if(header_field->id < GENERIC_HEADER_COUNT) { + status = mrcp_header_field_value_duplicate( + &header->generic_header_accessor, + &src_header->generic_header_accessor, + header_field->id, + &header_field->value, + pool); + } + else { + status = mrcp_header_field_value_duplicate( + &header->resource_header_accessor, + &src_header->resource_header_accessor, + header_field->id - GENERIC_HEADER_COUNT, + &header_field->value, + pool); + } + return status; +} + /** Set (copy) MRCP header fields */ MRCP_DECLARE(apt_bool_t) mrcp_header_fields_set(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, apr_pool_t *pool) { @@ -116,62 +139,51 @@ MRCP_DECLARE(apt_bool_t) mrcp_header_fields_set(mrcp_message_header_t *header, c src_header_field != APR_RING_SENTINEL(&src_header->header_section.ring, apt_header_field_t, link); src_header_field = APR_RING_NEXT(src_header_field, link)) { - header_field = apt_header_field_copy(src_header_field,pool); - if(header_field->id < GENERIC_HEADER_COUNT) { - if(mrcp_header_field_value_duplicate( - &header->generic_header_accessor, - &src_header->generic_header_accessor, - header_field->id, - &header_field->value, - pool) == TRUE) { - apt_header_section_field_add(&header->header_section,header_field); - } + header_field = apt_header_section_field_get(&header->header_section,src_header_field->id); + if(header_field) { + /* this header field has already been set, just copy its value */ + apt_string_copy(&header_field->value,&src_header_field->value,pool); } else { - if(mrcp_header_field_value_duplicate( - &header->resource_header_accessor, - &src_header->resource_header_accessor, - header_field->id - GENERIC_HEADER_COUNT, - &header_field->value, - pool) == TRUE) { - apt_header_section_field_add(&header->header_section,header_field); - } + /* copy the entire header field and add it to the header section */ + header_field = apt_header_field_copy(src_header_field,pool); + apt_header_section_field_add(&header->header_section,header_field); } + + mrcp_header_accessor_value_duplicate(header,header_field,src_header,src_header_field,pool); } return TRUE; } /** Get (copy) MRCP header fields */ -MRCP_DECLARE(apt_bool_t) mrcp_header_fields_get(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, apr_pool_t *pool) +MRCP_DECLARE(apt_bool_t) mrcp_header_fields_get(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, const mrcp_message_header_t *mask_header, apr_pool_t *pool) { apt_header_field_t *header_field; const apt_header_field_t *src_header_field; - for(header_field = APR_RING_FIRST(&header->header_section.ring); - header_field != APR_RING_SENTINEL(&header->header_section.ring, apt_header_field_t, link); - header_field = APR_RING_NEXT(header_field, link)) { + const apt_header_field_t *mask_header_field; + for(mask_header_field = APR_RING_FIRST(&mask_header->header_section.ring); + mask_header_field != APR_RING_SENTINEL(&mask_header->header_section.ring, apt_header_field_t, link); + mask_header_field = APR_RING_NEXT(mask_header_field, link)) { - src_header_field = apt_header_section_field_get(&src_header->header_section,header_field->id); - if(src_header_field) { - if(header_field->id < GENERIC_HEADER_COUNT) { - apt_string_copy(&header_field->value,&src_header_field->value,pool); - mrcp_header_field_value_duplicate( - &header->generic_header_accessor, - &src_header->generic_header_accessor, - header_field->id, - &header_field->value, - pool); - } - else { - apt_string_copy(&header_field->value,&src_header_field->value,pool); - mrcp_header_field_value_duplicate( - &header->resource_header_accessor, - &src_header->resource_header_accessor, - header_field->id - GENERIC_HEADER_COUNT, - &header_field->value, - pool); - } + header_field = apt_header_section_field_get(&header->header_section,mask_header_field->id); + if(header_field) { + /* this header field has already been set, skip to the next one */ + continue; } + + src_header_field = apt_header_section_field_get(&src_header->header_section,mask_header_field->id); + if(src_header_field) { + /* copy the entire header field */ + header_field = apt_header_field_copy(src_header_field,pool); + mrcp_header_accessor_value_duplicate(header,header_field,src_header,src_header_field,pool); + } + else { + /* copy only the name of the header field */ + header_field = apt_header_field_copy(mask_header_field,pool); + } + /* add the header field to the header section */ + apt_header_section_field_add(&header->header_section,header_field); } return TRUE; @@ -187,29 +199,15 @@ MRCP_DECLARE(apt_bool_t) mrcp_header_fields_inherit(mrcp_message_header_t *heade src_header_field = APR_RING_NEXT(src_header_field, link)) { header_field = apt_header_section_field_get(&header->header_section,src_header_field->id); - if(!header_field) { - header_field = apt_header_field_copy(src_header_field,pool); - if(header_field->id < GENERIC_HEADER_COUNT) { - if(mrcp_header_field_value_duplicate( - &header->generic_header_accessor, - &src_header->generic_header_accessor, - header_field->id, - &header_field->value, - pool) == TRUE) { - apt_header_section_field_add(&header->header_section,header_field); - } - } - else { - if(mrcp_header_field_value_duplicate( - &header->resource_header_accessor, - &src_header->resource_header_accessor, - header_field->id - GENERIC_HEADER_COUNT, - &header_field->value, - pool) == TRUE) { - apt_header_section_field_add(&header->header_section,header_field); - } - } + if(header_field) { + /* this header field has already been set, skip to the next one */ + continue; } + + /* copy the entire header field and add it to the header section */ + header_field = apt_header_field_copy(src_header_field,pool); + mrcp_header_accessor_value_duplicate(header,header_field,src_header,src_header_field,pool); + apt_header_section_field_add(&header->header_section,header_field); } return TRUE; } diff --git a/libs/unimrcp/libs/mrcp/message/src/mrcp_header_accessor.c b/libs/unimrcp/libs/mrcp/message/src/mrcp_header_accessor.c index c7148129cd..ffc113e457 100644 --- a/libs/unimrcp/libs/mrcp/message/src/mrcp_header_accessor.c +++ b/libs/unimrcp/libs/mrcp/message/src/mrcp_header_accessor.c @@ -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: mrcp_header_accessor.c 1737 2010-06-15 18:29:17Z achaloyan $ + * $Id: mrcp_header_accessor.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_header_accessor.h" diff --git a/libs/unimrcp/libs/mrcp/message/src/mrcp_message.c b/libs/unimrcp/libs/mrcp/message/src/mrcp_message.c index 3a37b2900f..e12aac85b6 100644 --- a/libs/unimrcp/libs/mrcp/message/src/mrcp_message.c +++ b/libs/unimrcp/libs/mrcp/message/src/mrcp_message.c @@ -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: mrcp_message.c 1701 2010-05-22 16:38:10Z achaloyan $ + * $Id: mrcp_message.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_message.h" diff --git a/libs/unimrcp/libs/mrcp/message/src/mrcp_start_line.c b/libs/unimrcp/libs/mrcp/message/src/mrcp_start_line.c index f2a36b0351..be20150d1d 100644 --- a/libs/unimrcp/libs/mrcp/message/src/mrcp_start_line.c +++ b/libs/unimrcp/libs/mrcp/message/src/mrcp_start_line.c @@ -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: mrcp_start_line.c 1671 2010-04-28 19:50:29Z achaloyan $ + * $Id: mrcp_start_line.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -443,7 +443,7 @@ MRCP_DECLARE(mrcp_request_id) mrcp_request_id_parse(const apt_str_t *field) /** Generate MRCP request-id */ MRCP_DECLARE(apt_bool_t) mrcp_request_id_generate(mrcp_request_id request_id, apt_text_stream_t *stream) { - int length = sprintf(stream->pos, "%"MRCP_REQUEST_ID_FMT, request_id); + int length = apr_snprintf(stream->pos, stream->end - stream->pos, "%"MRCP_REQUEST_ID_FMT, request_id); if(length <= 0) { return FALSE; } diff --git a/libs/unimrcp/libs/mrcp/mrcp.2008.vcproj b/libs/unimrcp/libs/mrcp/mrcp.2008.vcproj deleted file mode 100644 index 6f9eb5f0b5..0000000000 --- a/libs/unimrcp/libs/mrcp/mrcp.2008.vcproj +++ /dev/null @@ -1,446 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj.filters b/libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj.filters deleted file mode 100644 index 119921b34b..0000000000 --- a/libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj.filters +++ /dev/null @@ -1,133 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {19ad4bde-c4f4-4937-9073-ca2780341d76} - - - {8ec996ac-8a0a-4bf0-9b3c-535616585109} - h;hpp;hxx;hm;inl;inc;xsd - - - {5ba77874-7c17-4748-b5ba-b07b7f0a2169} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {f30fd049-a10d-4aea-b4bb-3eb674690fdd} - - - {7e71717b-6f22-4c59-ba50-7b5a15516b2f} - h;hpp;hxx;hm;inl;inc;xsd - - - {c66dbb84-ce9d-4408-b54d-4d0ec51069fb} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {f20cfd62-4bb9-42de-bf1c-d578c8cd1a18} - - - {039a4834-7ddb-40e7-9177-55d11ef1e733} - h;hpp;hxx;hm;inl;inc;xsd - - - {dc087d31-8ecf-473c-baa1-f3091e16014d} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - message\include - - - message\include - - - message\include - - - message\include - - - control\include - - - control\include - - - control\include - - - control\include - - - resources\include - - - resources\include - - - resources\include - - - resources\include - - - resources\include - - - resources\include - - - - - message\src - - - message\src - - - message\src - - - message\src - - - control\src - - - control\src - - - control\src - - - resources\src - - - resources\src - - - resources\src - - - resources\src - - - resources\src - - - resources\src - - - \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj b/libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj deleted file mode 100644 index f3f11ff9e4..0000000000 --- a/libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj +++ /dev/null @@ -1,158 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcp - {1C320193-46A6-4B34-9C56-8AB584FC1B56} - mrcp - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj b/libs/unimrcp/libs/mrcp/mrcp.vcxproj similarity index 75% rename from libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj rename to libs/unimrcp/libs/mrcp/mrcp.vcxproj index ed2c29bbf8..81fa915bac 100644 --- a/libs/unimrcp/libs/mrcp/mrcp.2010.vcxproj +++ b/libs/unimrcp/libs/mrcp/mrcp.vcxproj @@ -1,154 +1,157 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcp - {1C320193-46A6-4B34-9C56-8AB584FC1B56} - mrcp - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - %(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {1C320193-46A6-4B34-9C56-8AB584FC1B56} + mrcp + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + + + X64 + + + %(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + %(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj.filters b/libs/unimrcp/libs/mrcp/mrcp.vcxproj.filters similarity index 83% rename from libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj.filters rename to libs/unimrcp/libs/mrcp/mrcp.vcxproj.filters index 03e7ae72e8..300f13fdf6 100644 --- a/libs/unimrcp/libs/mrcp/mrcp.2012.vcxproj.filters +++ b/libs/unimrcp/libs/mrcp/mrcp.vcxproj.filters @@ -1,151 +1,151 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {19ad4bde-c4f4-4937-9073-ca2780341d76} - - - {8ec996ac-8a0a-4bf0-9b3c-535616585109} - h;hpp;hxx;hm;inl;inc;xsd - - - {5ba77874-7c17-4748-b5ba-b07b7f0a2169} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {f30fd049-a10d-4aea-b4bb-3eb674690fdd} - - - {7e71717b-6f22-4c59-ba50-7b5a15516b2f} - h;hpp;hxx;hm;inl;inc;xsd - - - {c66dbb84-ce9d-4408-b54d-4d0ec51069fb} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {f20cfd62-4bb9-42de-bf1c-d578c8cd1a18} - - - {039a4834-7ddb-40e7-9177-55d11ef1e733} - h;hpp;hxx;hm;inl;inc;xsd - - - {dc087d31-8ecf-473c-baa1-f3091e16014d} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - message\include - - - message\include - - - message\include - - - message\include - - - control\include - - - control\include - - - control\include - - - control\include - - - resources\include - - - resources\include - - - resources\include - - - resources\include - - - resources\include - - - resources\include - - - include - - - include - - - include - - - - - message\src - - - message\src - - - message\src - - - message\src - - - control\src - - - control\src - - - control\src - - - resources\src - - - resources\src - - - resources\src - - - resources\src - - - resources\src - - - resources\src - - - message\src - - - message\src - - - message\src - - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {235b9544-2004-49c6-96de-a5830544296e} + + + {64717899-118b-46de-8646-d7312b19ce00} + h;hpp;hxx;hm;inl;inc;xsd + + + {1b656d42-e8f0-4126-85da-9bb8a470cfaa} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {39545f85-6811-4878-af3f-26d813012ea3} + + + {e165b2a9-81db-4030-9e72-7189ee45182b} + h;hpp;hxx;hm;inl;inc;xsd + + + {a4e3b1a7-762d-4fcf-83e8-f52675aab2ff} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {35e8458d-fc25-4066-b4be-ab452a6da8a9} + + + {8bbdedd2-2c1e-4474-8dbb-fcecf1f9a869} + h;hpp;hxx;hm;inl;inc;xsd + + + {1d167695-a5d2-4f87-8bd3-ea21cea5a368} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + message\include + + + message\include + + + message\include + + + message\include + + + message\include + + + control\include + + + control\include + + + control\include + + + control\include + + + resources\include + + + resources\include + + + resources\include + + + resources\include + + + resources\include + + + resources\include + + + resources\include + + + resources\include + + + + + message\src + + + message\src + + + message\src + + + message\src + + + message\src + + + control\src + + + control\src + + + control\src + + + resources\src + + + resources\src + + + resources\src + + + resources\src + + + resources\src + + + resources\src + + + resources\src + + + resources\src + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_header.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_header.h index 40556d5790..a9f71c5a7e 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_header.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_header.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: mrcp_recog_header.h 1736 2010-06-14 20:16:22Z achaloyan $ + * $Id: mrcp_recog_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECOG_HEADER_H diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_resource.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_resource.h index 64eddd9290..93e2f1ba9e 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_resource.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_resource.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: mrcp_recog_resource.h 1781 2010-09-01 07:33:00Z achaloyan $ + * $Id: mrcp_recog_resource.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECOG_RESOURCE_H diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_header.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_header.h index 2fadba5ea8..77569a00b0 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_header.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_header.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: mrcp_recorder_header.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recorder_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECORDER_HEADER_H diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_resource.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_resource.h index 090992ba62..86100030a1 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_resource.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_recorder_resource.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: mrcp_recorder_resource.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recorder_resource.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_RECORDER_RESOURCE_H diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_header.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_header.h index c711414471..9a9fc6eb6b 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_header.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_header.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: mrcp_synth_header.h 1643 2010-04-08 13:40:09Z achaloyan $ + * $Id: mrcp_synth_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SYNTH_HEADER_H @@ -201,7 +201,7 @@ struct mrcp_prosody_volume_t { /** prosody-volume value */ union { - /** one of "silent", "x-soft,..." */ + /** one of "silent", "x-soft", ... */ mrcp_prosody_volume_label_e label; /** numeric value */ float numeric; @@ -217,7 +217,7 @@ struct mrcp_prosody_rate_t { /** prosody-rate value */ union { - /** one of "x-slow", "slow,..." */ + /** one of "x-slow", "slow", ... */ mrcp_prosody_rate_label_e label; /** relative change */ float relative; diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_resource.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_resource.h index 256be1ac3c..a03cc53e55 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_resource.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_resource.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: mrcp_synth_resource.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_synth_resource.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SYNTH_RESOURCE_H diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_header.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_header.h index cac29e01d1..7a7e94419a 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_header.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_header.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. diff --git a/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_resource.h b/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_resource.h index 5fcfaef2ce..f3022513eb 100644 --- a/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_resource.h +++ b/libs/unimrcp/libs/mrcp/resources/include/mrcp_verifier_resource.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. diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c index 81ae07507d..527476c303 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c @@ -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: mrcp_recog_header.c 1736 2010-06-14 20:16:22Z achaloyan $ + * $Id: mrcp_recog_header.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_recog_header.h" diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_resource.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_resource.c index 108e1f638a..83a1a4e83e 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_resource.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_resource.c @@ -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: mrcp_recog_resource.c 1781 2010-09-01 07:33:00Z achaloyan $ + * $Id: mrcp_recog_resource.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_recog_resource.h" diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_header.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_header.c index fdfea41373..85f619524a 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_header.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_header.c @@ -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: mrcp_recorder_header.c 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: mrcp_recorder_header.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_recorder_header.h" diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_resource.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_resource.c index 24254c1a7c..28f4844f4e 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_resource.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_recorder_resource.c @@ -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: mrcp_recorder_resource.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_recorder_resource.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_recorder_resource.h" diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c index 45b88087d3..49e8c29ef3 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c @@ -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: mrcp_synth_header.c 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: mrcp_synth_header.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_synth_header.h" @@ -97,18 +97,6 @@ static APR_INLINE apr_size_t apt_string_table_value_parse(const apt_str_table_it return apt_string_table_id_find(string_table,count,value); } -static apt_bool_t apt_string_table_value_generate(const apt_str_table_item_t *string_table, apr_size_t count, apr_size_t id, apt_text_stream_t *stream) -{ - const apt_str_t *name = apt_string_table_str_get(string_table,count,id); - if(!name) { - return FALSE; - } - - memcpy(stream->pos,name->buf,name->length); - stream->pos += name->length; - return TRUE; -} - static apt_bool_t apt_string_table_value_pgenerate(const apt_str_table_item_t *string_table, apr_size_t count, apr_size_t id, apt_str_t *str, apr_pool_t *pool) { const apt_str_t *name = apt_string_table_str_get(string_table,count,id); @@ -261,20 +249,19 @@ static apt_bool_t mrcp_speech_length_generate(mrcp_speech_length_value_t *speech } } else { - char buf[256]; - apt_text_stream_t stream; - apt_text_stream_init(&stream,buf,sizeof(buf)); - if(speech_length->type == SPEECH_LENGTH_TYPE_NUMERIC_POSITIVE) { - *stream.pos++ = '+'; + const apt_str_t *unit_name = apt_string_table_str_get( + speech_unit_string_table, + SPEECH_UNIT_COUNT, + speech_length->value.numeric.unit); + if(!unit_name) { + return FALSE; } - else { - *stream.pos++ = '-'; - } - apt_text_size_value_insert(&stream,speech_length->value.numeric.length); - *stream.pos++ = APT_TOKEN_SP; - apt_string_table_value_generate(speech_unit_string_table,SPEECH_UNIT_COUNT,speech_length->value.numeric.unit,&stream); - apt_string_assign_n(str,stream.text.buf, stream.pos - stream.text.buf, pool); + str->buf = apr_psprintf(pool, "%c%"APR_SIZE_T_FMT" %s", + speech_length->type == SPEECH_LENGTH_TYPE_NUMERIC_POSITIVE ? '+' : '-', + speech_length->value.numeric.length, + unit_name->buf); + str->length = strlen(str->buf); } return TRUE; } diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_resource.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_resource.c index fb17ce67e1..795672043c 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_resource.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_resource.c @@ -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: mrcp_synth_resource.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_synth_resource.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "mrcp_synth_resource.h" diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_header.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_header.c index 9a15924b43..a0c32d0424 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_header.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_header.c @@ -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. diff --git a/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_resource.c b/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_resource.c index 71d6b28c1f..6f430a6619 100644 --- a/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_resource.c +++ b/libs/unimrcp/libs/mrcp/resources/src/mrcp_verifier_resource.c @@ -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. diff --git a/libs/unimrcp/libs/mrcpv2-transport/Makefile.am b/libs/unimrcp/libs/mrcpv2-transport/Makefile.am index f70441e402..c2ffac4ef0 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/Makefile.am +++ b/libs/unimrcp/libs/mrcpv2-transport/Makefile.am @@ -1,11 +1,11 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcpv2-transport/include \ -I$(top_srcdir)/libs/mrcp/include \ -I$(top_srcdir)/libs/mrcp/message/include \ -I$(top_srcdir)/libs/mrcp/control/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libmrcpv2transport.la @@ -13,9 +13,11 @@ include_HEADERS = include/mrcp_connection_types.h \ include/mrcp_control_descriptor.h \ include/mrcp_connection.h \ include/mrcp_client_connection.h \ - include/mrcp_server_connection.h + include/mrcp_server_connection.h \ + include/mrcp_ca_factory.h libmrcpv2transport_la_SOURCES = src/mrcp_control_descriptor.c \ src/mrcp_connection.c \ src/mrcp_client_connection.c \ - src/mrcp_server_connection.c + src/mrcp_server_connection.c \ + src/mrcp_ca_factory.c diff --git a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_ca_factory.h b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_ca_factory.h new file mode 100644 index 0000000000..599a4e60b7 --- /dev/null +++ b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_ca_factory.h @@ -0,0 +1,45 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Id: mrcp_ca_factory.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ + */ + +#ifndef MRCP_CA_FACTORY_H +#define MRCP_CA_FACTORY_H + +/** + * @file mrcp_ca_factory.h + * @brief Factory of MRCPv2 Connection Agents + */ + +#include "mrcp_connection_types.h" + +APT_BEGIN_EXTERN_C + +/** Create factory of connection agents. */ +MRCP_DECLARE(mrcp_ca_factory_t*) mrcp_ca_factory_create(apr_pool_t *pool); + +/** Add connection agent to factory. */ +MRCP_DECLARE(apt_bool_t) mrcp_ca_factory_agent_add(mrcp_ca_factory_t *mpf_factory, mrcp_connection_agent_t *agent); + +/** Determine whether factory is empty. */ +MRCP_DECLARE(apt_bool_t) mrcp_ca_factory_is_empty(const mrcp_ca_factory_t *factory); + +/** Select next available agent. */ +MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_ca_factory_agent_select(mrcp_ca_factory_t *factory); + +APT_END_EXTERN_C + +#endif /* MRCP_CA_FACTORY_H */ diff --git a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_client_connection.h b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_client_connection.h index b8e83f5a5d..fd762bb1f9 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_client_connection.h +++ b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_client_connection.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: mrcp_client_connection.h 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_client_connection.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_CLIENT_CONNECTION_H diff --git a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection.h b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection.h index 08031c3a55..fd2f39dca0 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection.h +++ b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection.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: mrcp_connection.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_connection.h 2170 2014-09-09 05:19:48Z achaloyan@gmail.com $ */ #ifndef MRCP_CONNECTION_H @@ -26,7 +26,10 @@ #include #include -#include "apt_obj_list.h" +#ifdef WIN32 +#pragma warning(disable: 4127) +#endif +#include #include "mrcp_connection_types.h" #include "mrcp_stream.h" @@ -37,6 +40,9 @@ APT_BEGIN_EXTERN_C /** MRCPv2 connection */ struct mrcp_connection_t { + /** Ring entry */ + APR_RING_ENTRY(mrcp_connection_t) link; + /** Memory pool */ apr_pool_t *pool; @@ -58,8 +64,6 @@ struct mrcp_connection_t { /** Reference count */ apr_size_t access_count; - /** Agent list element */ - apt_list_elem_t *it; /** Opaque agent */ void *agent; @@ -84,7 +88,7 @@ struct mrcp_connection_t { }; /** Create MRCP connection. */ -mrcp_connection_t* mrcp_connection_create(); +mrcp_connection_t* mrcp_connection_create(void); /** Destroy MRCP connection. */ void mrcp_connection_destroy(mrcp_connection_t *connection); diff --git a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection_types.h b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection_types.h index e61c66cafa..6f98564dbd 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection_types.h +++ b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_connection_types.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: mrcp_connection_types.h 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_connection_types.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_CONNECTION_TYPES_H @@ -43,6 +43,9 @@ typedef struct mrcp_control_channel_t mrcp_control_channel_t; /** Opaque MRCPv2 connection agent declaration */ typedef struct mrcp_connection_agent_t mrcp_connection_agent_t; +/** Opaque MRCPv2 connection agent factory declaration */ +typedef struct mrcp_ca_factory_t mrcp_ca_factory_t; + /** MRCPv2 connection event vtable declaration */ typedef struct mrcp_connection_event_vtable_t mrcp_connection_event_vtable_t; diff --git a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_control_descriptor.h b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_control_descriptor.h index 40535d4b5b..9597970ddf 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_control_descriptor.h +++ b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_control_descriptor.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: mrcp_control_descriptor.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_control_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_CONTROL_DESCRIPTOR_H diff --git a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_server_connection.h b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_server_connection.h index a5ee18c1a2..df99cc1a40 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_server_connection.h +++ b/libs/unimrcp/libs/mrcpv2-transport/include/mrcp_server_connection.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: mrcp_server_connection.h 1721 2010-06-01 05:45:46Z achaloyan $ + * $Id: mrcp_server_connection.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SERVER_CONNECTION_H diff --git a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2008.vcproj b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2008.vcproj deleted file mode 100644 index 87ed8335a3..0000000000 --- a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2008.vcproj +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj deleted file mode 100644 index 64f3fb5ffc..0000000000 --- a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpv2transport - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} - mrcpv2transport - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcproj b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcproj index 20d8760150..526f1e36a3 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcproj +++ b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcproj @@ -240,6 +240,10 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + @@ -265,6 +269,10 @@ Name="src" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" > + + diff --git a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcxproj similarity index 65% rename from libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj rename to libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcxproj index 33ed618305..4d99d355c3 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj +++ b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcxproj @@ -1,124 +1,125 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpv2transport - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} - mrcpv2transport - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} + mrcpv2transport + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + X64 + + + ProgramDatabase + + + + + X64 + + + + + + + + + + + + + + + + + + + + {1c320193-46a6-4b34-9c56-8ab584fc1b56} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj.filters b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcxproj.filters similarity index 84% rename from libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj.filters rename to libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcxproj.filters index 452f77e19d..d573ce6367 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2012.vcxproj.filters +++ b/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.vcxproj.filters @@ -1,44 +1,50 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {a92d3b8c-d54d-416c-b458-dc57ac24d2e9} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - include - - - include - - - - - src - - - src - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {119450fa-653a-4fdc-9017-a4350ff3066c} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_ca_factory.c b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_ca_factory.c new file mode 100644 index 0000000000..b588ee200c --- /dev/null +++ b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_ca_factory.c @@ -0,0 +1,65 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Id: mrcp_ca_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ + */ + +#include +#include "mrcp_ca_factory.h" + +/** Factory of MRCPv2 connection agents */ +struct mrcp_ca_factory_t { + /** Array of pointers to agents */ + apr_array_header_t *agent_arr; + /** Index of the current agent */ + int index; +}; + +/** Create factory of connection agents. */ +MRCP_DECLARE(mrcp_ca_factory_t*) mrcp_ca_factory_create(apr_pool_t *pool) +{ + mrcp_ca_factory_t *factory = apr_palloc(pool,sizeof(mrcp_ca_factory_t)); + factory->agent_arr = apr_array_make(pool,1,sizeof(mrcp_connection_agent_t*)); + factory->index = 0; + return factory; +} + +/** Add connection agent to factory. */ +MRCP_DECLARE(apt_bool_t) mrcp_ca_factory_agent_add(mrcp_ca_factory_t *factory, mrcp_connection_agent_t *agent) +{ + mrcp_connection_agent_t **slot; + if(!agent) + return FALSE; + + slot = apr_array_push(factory->agent_arr); + *slot = agent; + return TRUE; +} + +/** Determine whether factory is empty. */ +MRCP_DECLARE(apt_bool_t) mrcp_ca_factory_is_empty(const mrcp_ca_factory_t *factory) +{ + return apr_is_empty_array(factory->agent_arr); +} + +/** Select next available agent. */ +MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_ca_factory_agent_select(mrcp_ca_factory_t *factory) +{ + mrcp_connection_agent_t *agent = APR_ARRAY_IDX(factory->agent_arr, factory->index, mrcp_connection_agent_t*); + if(++factory->index == factory->agent_arr->nelts) { + factory->index = 0; + } + return agent; +} diff --git a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_client_connection.c b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_client_connection.c index 5d67271fa8..99006b72bc 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_client_connection.c +++ b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_client_connection.c @@ -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: mrcp_client_connection.c 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_client_connection.c 2235 2014-11-12 01:41:51Z achaloyan@gmail.com $ */ #include "mrcp_connection.h" @@ -27,12 +27,13 @@ struct mrcp_connection_agent_t { + /** List (ring) of MRCP connections */ + APR_RING_HEAD(mrcp_connection_head_t, mrcp_connection_t) connection_list; + apr_pool_t *pool; apt_poller_task_t *task; const mrcp_resource_factory_t *resource_factory; - apt_obj_list_t *connection_list; - apr_uint32_t request_timeout; apt_bool_t offer_new_connection; apr_size_t tx_buffer_size; @@ -74,7 +75,7 @@ MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_client_connection_agent_create( apt_task_vtable_t *vtable; apt_task_msg_pool_t *msg_pool; mrcp_connection_agent_t *agent; - + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCPv2 Agent [%s] [%"APR_SIZE_T_FMT"]", id, max_connection_count); agent = apr_palloc(pool,sizeof(mrcp_connection_agent_t)); @@ -106,7 +107,7 @@ MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_client_connection_agent_create( vtable->process_msg = mrcp_client_agent_msg_process; } - agent->connection_list = apt_list_create(pool); + APR_RING_INIT(&agent->connection_list, mrcp_connection_t, link); return agent; } @@ -287,7 +288,6 @@ static mrcp_connection_t* mrcp_client_agent_connection_create(mrcp_connection_ag { char *local_ip = NULL; char *remote_ip = NULL; - apt_pollset_t *pollset = apt_poller_task_pollset_get(agent->task); mrcp_connection_t *connection = mrcp_connection_create(); apr_sockaddr_info_get(&connection->r_sockaddr,descriptor->ip.buf,APR_INET,descriptor->port,0,connection->pool); @@ -328,7 +328,7 @@ static mrcp_connection_t* mrcp_client_agent_connection_create(mrcp_connection_ag connection->sock_pfd.reqevents = APR_POLLIN; connection->sock_pfd.desc.s = connection->sock; connection->sock_pfd.client_data = connection; - if(apt_pollset_add(pollset, &connection->sock_pfd) != TRUE) { + if(apt_poller_task_descriptor_add(agent->task, &connection->sock_pfd) != TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add to Pollset %s",connection->id); apr_socket_close(connection->sock); mrcp_connection_destroy(connection); @@ -337,7 +337,7 @@ static mrcp_connection_t* mrcp_client_agent_connection_create(mrcp_connection_ag apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Established TCP/MRCPv2 Connection %s",connection->id); connection->agent = agent; - connection->it = apt_list_push_back(agent->connection_list,connection,connection->pool); + APR_RING_INSERT_TAIL(&agent->connection_list,connection,mrcp_connection_t,link); connection->parser = mrcp_parser_create(agent->resource_factory,connection->pool); connection->generator = mrcp_generator_create(agent->resource_factory,connection->pool); @@ -361,39 +361,30 @@ static mrcp_connection_t* mrcp_client_agent_connection_create(mrcp_connection_ag static mrcp_connection_t* mrcp_client_agent_connection_find(mrcp_connection_agent_t *agent, mrcp_control_descriptor_t *descriptor) { apr_sockaddr_t *sockaddr; - mrcp_connection_t *connection = NULL; - apt_list_elem_t *elem = apt_list_first_elem_get(agent->connection_list); - /* walk through the list of connections */ - while(elem) { - connection = apt_list_elem_object_get(elem); - if(connection) { - if(apr_sockaddr_info_get(&sockaddr,descriptor->ip.buf,APR_INET,descriptor->port,0,connection->pool) == APR_SUCCESS) { - if(apr_sockaddr_equal(sockaddr,connection->r_sockaddr) != 0 && - descriptor->port == connection->r_sockaddr->port) { - return connection; - } + mrcp_connection_t *connection; + + for(connection = APR_RING_FIRST(&agent->connection_list); + connection != APR_RING_SENTINEL(&agent->connection_list, mrcp_connection_t, link); + connection = APR_RING_NEXT(connection, link)) { + if(apr_sockaddr_info_get(&sockaddr,descriptor->ip.buf,APR_INET,descriptor->port,0,connection->pool) == APR_SUCCESS) { + if(apr_sockaddr_equal(sockaddr,connection->r_sockaddr) != 0 && + descriptor->port == connection->r_sockaddr->port) { + return connection; } } - elem = apt_list_next_elem_get(agent->connection_list,elem); } + return NULL; } static apt_bool_t mrcp_client_agent_connection_remove(mrcp_connection_agent_t *agent, mrcp_connection_t *connection) { - apt_pollset_t *pollset = apt_poller_task_pollset_get(agent->task); - /* remove from the list */ - if(connection->it) { - apt_list_elem_remove(agent->connection_list,connection->it); - connection->it = NULL; - } - - if(pollset) { - apt_pollset_remove(pollset,&connection->sock_pfd); - } + APR_RING_REMOVE(connection,link); + if(connection->sock) { apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close TCP/MRCPv2 Connection %s",connection->id); + apt_poller_task_descriptor_remove(agent->task,&connection->sock_pfd); apr_socket_close(connection->sock); connection->sock = NULL; } @@ -407,7 +398,7 @@ static apt_bool_t mrcp_client_agent_channel_add(mrcp_connection_agent_t *agent, } else { descriptor->connection_type = MRCP_CONNECTION_TYPE_EXISTING; - if(apt_list_is_empty(agent->connection_list) == TRUE) { + if(APR_RING_EMPTY(&agent->connection_list, mrcp_connection_t, link)) { /* offer new connection if there is no established connection yet */ descriptor->connection_type = MRCP_CONNECTION_TYPE_NEW; } @@ -629,11 +620,8 @@ static apt_bool_t mrcp_client_poller_signal_process(void *obj, const apr_pollfd_ status = apr_socket_recv(connection->sock,stream->pos,&length); if(status == APR_EOF || length == 0) { - apt_pollset_t *pollset = apt_poller_task_pollset_get(agent->task); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"TCP/MRCPv2 Peer Disconnected %s",connection->id); - if(pollset) { - apt_pollset_remove(pollset,&connection->sock_pfd); - } + apt_poller_task_descriptor_remove(agent->task,&connection->sock_pfd); apr_socket_close(connection->sock); connection->sock = NULL; diff --git a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_connection.c b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_connection.c index 29a06abd87..bf9dc75d2c 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_connection.c +++ b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_connection.c @@ -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,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mrcp_connection.c 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_connection.c 2170 2014-09-09 05:19:48Z achaloyan@gmail.com $ */ #include "mrcp_connection.h" #include "apt_pool.h" -mrcp_connection_t* mrcp_connection_create() +mrcp_connection_t* mrcp_connection_create(void) { mrcp_connection_t *connection; apr_pool_t *pool = apt_pool_create(); @@ -36,7 +36,7 @@ mrcp_connection_t* mrcp_connection_create() connection->id = NULL; connection->verbose = TRUE; connection->access_count = 0; - connection->it = NULL; + APR_RING_ELEM_INIT(connection,link); connection->channel_table = apr_hash_make(pool); connection->parser = NULL; connection->generator = NULL; diff --git a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_control_descriptor.c b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_control_descriptor.c index 0f8fd8b1f4..2339e8fb56 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_control_descriptor.c +++ b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_control_descriptor.c @@ -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: mrcp_control_descriptor.c 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: mrcp_control_descriptor.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_string_table.h" diff --git a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_server_connection.c b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_server_connection.c index f85a3813cd..67fd4561c9 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_server_connection.c +++ b/libs/unimrcp/libs/mrcpv2-transport/src/mrcp_server_connection.c @@ -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: mrcp_server_connection.c 1792 2011-01-10 21:08:52Z achaloyan $ + * $Id: mrcp_server_connection.c 2235 2014-11-12 01:41:51Z achaloyan@gmail.com $ */ #include "mrcp_connection.h" @@ -32,8 +32,10 @@ struct mrcp_connection_agent_t { apt_poller_task_t *task; const mrcp_resource_factory_t *resource_factory; - apt_obj_list_t *connection_list; - mrcp_connection_t *null_connection; + /** List (ring) of MRCP connections */ + APR_RING_HEAD(mrcp_connection_head_t, mrcp_connection_t) connection_list; + /** Table of pending control channels */ + apr_hash_t *pending_channel_table; apt_bool_t force_new_connection; apr_size_t tx_buffer_size; @@ -100,7 +102,7 @@ MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_server_connection_agent_create( agent->rx_buffer_size = MRCP_STREAM_BUFFER_SIZE; agent->tx_buffer_size = MRCP_STREAM_BUFFER_SIZE; - apr_sockaddr_info_get(&agent->sockaddr,listen_ip,APR_INET,listen_port,0,agent->pool); + apr_sockaddr_info_get(&agent->sockaddr,listen_ip,APR_INET,listen_port,0,pool); if(!agent->sockaddr) { return NULL; } @@ -128,24 +130,14 @@ MRCP_DECLARE(mrcp_connection_agent_t*) mrcp_server_connection_agent_create( vtable->process_msg = mrcp_server_agent_msg_process; } - agent->connection_list = NULL; - agent->null_connection = NULL; + APR_RING_INIT(&agent->connection_list, mrcp_connection_t, link); + agent->pending_channel_table = apr_hash_make(pool); - if(mrcp_server_agent_listening_socket_create(agent) == TRUE) { - /* add listening socket to pollset */ - apt_pollset_t *pollset = apt_poller_task_pollset_get(agent->task); - memset(&agent->listen_sock_pfd,0,sizeof(apr_pollfd_t)); - agent->listen_sock_pfd.desc_type = APR_POLL_SOCKET; - agent->listen_sock_pfd.reqevents = APR_POLLIN; - agent->listen_sock_pfd.desc.s = agent->listen_sock; - agent->listen_sock_pfd.client_data = agent->listen_sock; - if(apt_pollset_add(pollset, &agent->listen_sock_pfd) != TRUE) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add Listening Socket to Pollset"); - mrcp_server_agent_listening_socket_destroy(agent); - } - } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Listening Socket"); + if(mrcp_server_agent_listening_socket_create(agent) != TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Listening Socket [%s] %s:%hu", + id, + listen_ip, + listen_port); } return agent; } @@ -155,12 +147,7 @@ static apt_bool_t mrcp_server_agent_on_destroy(apt_task_t *task) apt_poller_task_t *poller_task = apt_task_object_get(task); mrcp_connection_agent_t *agent = apt_poller_task_object_get(poller_task); - apt_pollset_t *pollset = apt_poller_task_pollset_get(poller_task); - if(pollset) { - apt_pollset_remove(pollset,&agent->listen_sock_pfd); - } mrcp_server_agent_listening_socket_destroy(agent); - apt_poller_task_cleanup(poller_task); return TRUE; } @@ -187,8 +174,8 @@ MRCP_DECLARE(apt_bool_t) mrcp_server_connection_agent_terminate(mrcp_connection_ /** Set connection event handler. */ MRCP_DECLARE(void) mrcp_server_connection_agent_handler_set( - mrcp_connection_agent_t *agent, - void *obj, + mrcp_connection_agent_t *agent, + void *obj, const mrcp_connection_event_vtable_t *vtable) { agent->obj = obj; @@ -197,7 +184,7 @@ MRCP_DECLARE(void) mrcp_server_connection_agent_handler_set( /** Set MRCP resource factory */ MRCP_DECLARE(void) mrcp_server_connection_resource_factory_set( - mrcp_connection_agent_t *agent, + mrcp_connection_agent_t *agent, const mrcp_resource_factory_t *resource_factroy) { agent->resource_factory = resource_factroy; @@ -318,6 +305,7 @@ MRCP_DECLARE(apt_bool_t) mrcp_server_control_message_send(mrcp_control_channel_t return mrcp_server_control_message_signal(CONNECTION_TASK_MSG_SEND_MESSAGE,channel->agent,channel,NULL,message); } +/** Create listening socket and add it to pollset */ static apt_bool_t mrcp_server_agent_listening_socket_create(mrcp_connection_agent_t *agent) { apr_status_t status; @@ -348,12 +336,28 @@ static apt_bool_t mrcp_server_agent_listening_socket_create(mrcp_connection_agen return FALSE; } + /* add listening socket to pollset */ + memset(&agent->listen_sock_pfd,0,sizeof(apr_pollfd_t)); + agent->listen_sock_pfd.desc_type = APR_POLL_SOCKET; + agent->listen_sock_pfd.reqevents = APR_POLLIN; + agent->listen_sock_pfd.desc.s = agent->listen_sock; + agent->listen_sock_pfd.client_data = agent->listen_sock; + if(apt_poller_task_descriptor_add(agent->task, &agent->listen_sock_pfd) != TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add Listening Socket to Pollset [%s]", + apt_task_name_get(apt_poller_task_base_get(agent->task))); + apr_socket_close(agent->listen_sock); + agent->listen_sock = NULL; + return FALSE; + } + return TRUE; } +/** Remove from pollset and destroy listening socket */ static void mrcp_server_agent_listening_socket_destroy(mrcp_connection_agent_t *agent) { if(agent->listen_sock) { + apt_poller_task_descriptor_remove(agent->task,&agent->listen_sock_pfd); apr_socket_close(agent->listen_sock); agent->listen_sock = NULL; } @@ -369,13 +373,14 @@ static mrcp_control_channel_t* mrcp_connection_channel_associate(mrcp_connection apt_id_resource_generate(&message->channel_id.session_id,&message->channel_id.resource_name,'@',&identifier,connection->pool); channel = mrcp_connection_channel_find(connection,&identifier); if(!channel) { - channel = mrcp_connection_channel_find(agent->null_connection,&identifier); + channel = apr_hash_get(agent->pending_channel_table,identifier.buf,identifier.length); if(channel) { - mrcp_connection_channel_remove(agent->null_connection,channel); + apr_hash_set(agent->pending_channel_table,identifier.buf,identifier.length,NULL); mrcp_connection_channel_add(connection,channel); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Attach Control Channel <%s> to Connection %s [%d]", + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Assign Control Channel <%s> to Connection %s [%d] -> [%d]", channel->identifier.buf, connection->id, + apr_hash_count(agent->pending_channel_table), apr_hash_count(connection->channel_table)); } } @@ -384,40 +389,25 @@ static mrcp_control_channel_t* mrcp_connection_channel_associate(mrcp_connection static mrcp_connection_t* mrcp_connection_find(mrcp_connection_agent_t *agent, const apt_str_t *remote_ip) { - mrcp_connection_t *connection = NULL; - apt_list_elem_t *elem; - if(!agent || !agent->connection_list || !remote_ip) { + mrcp_connection_t *connection; + if(!agent || !remote_ip) { return NULL; } - elem = apt_list_first_elem_get(agent->connection_list); - /* walk through the list of connections */ - while(elem) { - connection = apt_list_elem_object_get(elem); - if(connection) { - if(apt_string_compare(&connection->remote_ip,remote_ip) == TRUE) { - return connection; - } + for(connection = APR_RING_FIRST(&agent->connection_list); + connection != APR_RING_SENTINEL(&agent->connection_list, mrcp_connection_t, link); + connection = APR_RING_NEXT(connection, link)) { + if(apt_string_compare(&connection->remote_ip,remote_ip) == TRUE) { + return connection; } - elem = apt_list_next_elem_get(agent->connection_list,elem); } + return NULL; } static apt_bool_t mrcp_connection_remove(mrcp_connection_agent_t *agent, mrcp_connection_t *connection) { - if(connection->it) { - apt_list_elem_remove(agent->connection_list,connection->it); - connection->it = NULL; - } - if(agent->null_connection) { - if(apt_list_is_empty(agent->connection_list) == TRUE && apr_hash_count(agent->null_connection->channel_table) == 0) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Destroy Container for Pending Control Channels"); - mrcp_connection_destroy(agent->null_connection); - agent->null_connection = NULL; - agent->connection_list = NULL; - } - } + APR_RING_REMOVE(connection,link); return TRUE; } @@ -425,36 +415,19 @@ static apt_bool_t mrcp_server_agent_connection_accept(mrcp_connection_agent_t *a { char *local_ip = NULL; char *remote_ip = NULL; - apr_socket_t *sock; - apr_pool_t *pool; - apt_pollset_t *pollset = apt_poller_task_pollset_get(agent->task); - mrcp_connection_t *connection; + + mrcp_connection_t *connection = mrcp_connection_create(); - if(!agent->null_connection) { - pool = apt_pool_create(); - if(apr_socket_accept(&sock,agent->listen_sock,pool) != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Accept Connection"); - return FALSE; - } - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Rejected TCP/MRCPv2 Connection"); - apr_socket_close(sock); - apr_pool_destroy(pool); - return FALSE; - } - - pool = agent->null_connection->pool; - if(apr_socket_accept(&sock,agent->listen_sock,pool) != APR_SUCCESS) { + if(apr_socket_accept(&connection->sock,agent->listen_sock,connection->pool) != APR_SUCCESS) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Accept Connection"); + mrcp_connection_destroy(connection); return FALSE; } - connection = mrcp_connection_create(); - connection->sock = sock; - - if(apr_socket_addr_get(&connection->r_sockaddr,APR_REMOTE,sock) != APR_SUCCESS || - apr_socket_addr_get(&connection->l_sockaddr,APR_LOCAL,sock) != APR_SUCCESS) { + if(apr_socket_addr_get(&connection->r_sockaddr,APR_REMOTE,connection->sock) != APR_SUCCESS || + apr_socket_addr_get(&connection->l_sockaddr,APR_LOCAL,connection->sock) != APR_SUCCESS) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Socket Address"); - apr_socket_close(sock); + apr_socket_close(connection->sock); mrcp_connection_destroy(connection); return FALSE; } @@ -466,21 +439,28 @@ static apt_bool_t mrcp_server_agent_connection_accept(mrcp_connection_agent_t *a local_ip,connection->l_sockaddr->port, remote_ip,connection->r_sockaddr->port); + if(apr_hash_count(agent->pending_channel_table) == 0) { + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Reject Unexpected TCP/MRCPv2 Connection %s",connection->id); + apr_socket_close(connection->sock); + mrcp_connection_destroy(connection); + return FALSE; + } + memset(&connection->sock_pfd,0,sizeof(apr_pollfd_t)); connection->sock_pfd.desc_type = APR_POLL_SOCKET; connection->sock_pfd.reqevents = APR_POLLIN; connection->sock_pfd.desc.s = connection->sock; connection->sock_pfd.client_data = connection; - if(apt_pollset_add(pollset, &connection->sock_pfd) != TRUE) { + if(apt_poller_task_descriptor_add(agent->task, &connection->sock_pfd) != TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add to Pollset %s",connection->id); - apr_socket_close(sock); + apr_socket_close(connection->sock); mrcp_connection_destroy(connection); return FALSE; } apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Accepted TCP/MRCPv2 Connection %s",connection->id); connection->agent = agent; - connection->it = apt_list_push_back(agent->connection_list,connection,connection->pool); + APR_RING_INSERT_TAIL(&agent->connection_list,connection,mrcp_connection_t,link); connection->parser = mrcp_parser_create(agent->resource_factory,connection->pool); connection->generator = mrcp_generator_create(agent->resource_factory,connection->pool); @@ -502,9 +482,8 @@ static apt_bool_t mrcp_server_agent_connection_accept(mrcp_connection_agent_t *a static apt_bool_t mrcp_server_agent_connection_close(mrcp_connection_agent_t *agent, mrcp_connection_t *connection) { - apt_pollset_t *pollset = apt_poller_task_pollset_get(agent->task); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"TCP/MRCPv2 Peer Disconnected %s",connection->id); - apt_pollset_remove(pollset,&connection->sock_pfd); + apt_poller_task_descriptor_remove(agent->task,&connection->sock_pfd); apr_socket_close(connection->sock); connection->sock = NULL; if(!connection->access_count) { @@ -538,15 +517,10 @@ static apt_bool_t mrcp_server_agent_channel_add(mrcp_connection_agent_t *agent, } } - if(!agent->null_connection) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create Container for Pending Control Channels"); - agent->null_connection = mrcp_connection_create(); - agent->connection_list = apt_list_create(agent->null_connection->pool); - } - mrcp_connection_channel_add(agent->null_connection,channel); + apr_hash_set(agent->pending_channel_table,channel->identifier.buf,channel->identifier.length,channel); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Pending Control Channel <%s> [%d]", channel->identifier.buf, - apr_hash_count(agent->null_connection->channel_table)); + apr_hash_count(agent->pending_channel_table)); /* send response */ return mrcp_control_channel_add_respond(agent->vtable,channel,answer,TRUE); } @@ -565,26 +539,26 @@ static apt_bool_t mrcp_server_agent_channel_modify(mrcp_connection_agent_t *agen static apt_bool_t mrcp_server_agent_channel_remove(mrcp_connection_agent_t *agent, mrcp_control_channel_t *channel) { mrcp_connection_t *connection = channel->connection; - mrcp_connection_channel_remove(connection,channel); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove Control Channel <%s> [%d]", - channel->identifier.buf, - apr_hash_count(connection->channel_table)); - if(!connection->access_count) { - if(connection == agent->null_connection) { - if(apt_list_is_empty(agent->connection_list) == TRUE) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Destroy Container for Pending Control Channels"); - mrcp_connection_destroy(agent->null_connection); - agent->null_connection = NULL; - agent->connection_list = NULL; + if(connection) { + mrcp_connection_channel_remove(connection,channel); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove Control Channel <%s> [%d]", + channel->identifier.buf, + apr_hash_count(connection->channel_table)); + if(!connection->access_count) { + if(!connection->sock) { + mrcp_connection_remove(agent,connection); + /* set connection to be destroyed on channel destroy */ + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Mark Connection for Removal %s",connection->id); + channel->connection = connection; + channel->removed = TRUE; } } - else if(!connection->sock) { - mrcp_connection_remove(agent,connection); - /* set connection to be destroyed on channel destroy */ - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Mark Connection for Removal %s",connection->id); - channel->connection = connection; - channel->removed = TRUE; - } + } + else { + apr_hash_set(agent->pending_channel_table,channel->identifier.buf,channel->identifier.length,NULL); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove Pending Control Channel <%s> [%d]", + channel->identifier.buf, + apr_hash_count(agent->pending_channel_table)); } /* send response */ return mrcp_control_channel_remove_respond(agent->vtable,channel,TRUE); diff --git a/libs/unimrcp/libs/uni-rtsp/Makefile.am b/libs/unimrcp/libs/uni-rtsp/Makefile.am index 45c7442a61..f058b8d94b 100644 --- a/libs/unimrcp/libs/uni-rtsp/Makefile.am +++ b/libs/unimrcp/libs/uni-rtsp/Makefile.am @@ -1,8 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/uni-rtsp/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_LTLIBRARIES = libunirtsp.la diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp.h index fbc55d6ef1..89ecb81776 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp.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: rtsp.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: rtsp.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_H diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp_client.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp_client.h index 0209e7211a..811ccb304f 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp_client.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp_client.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: rtsp_client.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: rtsp_client.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_CLIENT_H @@ -51,6 +51,7 @@ struct rtsp_client_vtable_t { /** * Create RTSP client. + * @param id the identifier of the client * @param max_connection_count the number of max RTSP connections * @param request_timeout the request timeout to set * @param obj the external object to send event to @@ -58,11 +59,12 @@ struct rtsp_client_vtable_t { * @param pool the pool to allocate memory from */ RTSP_DECLARE(rtsp_client_t*) rtsp_client_create( - apr_size_t max_connection_count, - apr_size_t request_timeout, - void *obj, - const rtsp_client_vtable_t *handler, - apr_pool_t *pool); + const char *id, + apr_size_t max_connection_count, + apr_size_t request_timeout, + void *obj, + const rtsp_client_vtable_t *handler, + apr_pool_t *pool); /** * Destroy RTSP client. diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp_header.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp_header.h index 4345ad4606..7d5c6cb350 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp_header.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp_header.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: rtsp_header.h 1648 2010-04-12 20:03:59Z achaloyan $ + * $Id: rtsp_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_HEADER_H diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp_message.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp_message.h index 71546d31e5..a636bc4de7 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp_message.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp_message.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: rtsp_message.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: rtsp_message.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_MESSAGE_H diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp_server.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp_server.h index 19e2131fb3..8da0bf41ff 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp_server.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp_server.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: rtsp_server.h 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: rtsp_server.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_SERVER_H @@ -49,6 +49,7 @@ struct rtsp_server_vtable_t { /** * Create RTSP server. + * @param id the identifier of the server * @param listen_ip the listen IP address * @param listen_port the listen port * @param max_connection_count the number of max RTSP connections @@ -57,12 +58,13 @@ struct rtsp_server_vtable_t { * @param pool the pool to allocate memory from */ RTSP_DECLARE(rtsp_server_t*) rtsp_server_create( - const char *listen_ip, - apr_port_t listen_port, - apr_size_t max_connection_count, - void *obj, - const rtsp_server_vtable_t *handler, - apr_pool_t *pool); + const char *id, + const char *listen_ip, + apr_port_t listen_port, + apr_size_t max_connection_count, + void *obj, + const rtsp_server_vtable_t *handler, + apr_pool_t *pool); /** * Destroy RTSP server. diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp_start_line.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp_start_line.h index 8fe8c85c37..dd53193d43 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp_start_line.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp_start_line.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: rtsp_start_line.h 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: rtsp_start_line.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_START_LINE_H diff --git a/libs/unimrcp/libs/uni-rtsp/include/rtsp_stream.h b/libs/unimrcp/libs/uni-rtsp/include/rtsp_stream.h index ecebef6055..a4cc4e1385 100644 --- a/libs/unimrcp/libs/uni-rtsp/include/rtsp_stream.h +++ b/libs/unimrcp/libs/uni-rtsp/include/rtsp_stream.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: rtsp_stream.h 1632 2010-03-30 20:46:25Z achaloyan $ + * $Id: rtsp_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RTSP_STREAM_H diff --git a/libs/unimrcp/libs/uni-rtsp/src/rtsp_client.c b/libs/unimrcp/libs/uni-rtsp/src/rtsp_client.c index d71c10f7a9..8f90367d73 100644 --- a/libs/unimrcp/libs/uni-rtsp/src/rtsp_client.c +++ b/libs/unimrcp/libs/uni-rtsp/src/rtsp_client.c @@ -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,9 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: rtsp_client.c 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: rtsp_client.c 2220 2014-11-11 02:39:48Z achaloyan@gmail.com $ */ +#ifdef WIN32 +#pragma warning(disable: 4127) +#endif +#include #include #include "rtsp_client.h" #include "rtsp_stream.h" @@ -40,8 +44,8 @@ struct rtsp_client_t { apr_pool_t *pool; apt_poller_task_t *task; - apr_pool_t *sub_pool; - apt_obj_list_t *connection_list; + /** List (ring) of RTSP connections */ + APR_RING_HEAD(rtsp_client_connection_head_t, rtsp_client_connection_t) connection_list; apr_uint32_t request_timeout; @@ -51,6 +55,9 @@ struct rtsp_client_t { /** RTSP connection */ struct rtsp_client_connection_t { + /** Ring entry */ + APR_RING_ENTRY(rtsp_client_connection_t) link; + /** Memory pool */ apr_pool_t *pool; /** Connected socket */ @@ -61,8 +68,6 @@ struct rtsp_client_connection_t { const char *id; /** RTSP client, connection belongs to */ rtsp_client_t *client; - /** Element of the connection list in agent */ - apt_list_elem_t *it; /** Handle table (rtsp_client_session_t*) */ apr_hash_t *handle_table; @@ -134,23 +139,33 @@ static apt_bool_t rtsp_client_poller_signal_process(void *obj, const apr_pollfd_ static apt_bool_t rtsp_client_message_handler(rtsp_client_connection_t *rtsp_connection, rtsp_message_t *message, apt_message_status_e status); static apt_bool_t rtsp_client_message_send(rtsp_client_t *client, rtsp_client_connection_t *connection, rtsp_message_t *message); static apt_bool_t rtsp_client_session_message_process(rtsp_client_t *client, rtsp_client_session_t *session, rtsp_message_t *message); -static apt_bool_t rtsp_client_session_request_process(rtsp_client_t *client, rtsp_client_session_t *session, rtsp_message_t *message); static apt_bool_t rtsp_client_session_response_process(rtsp_client_t *client, rtsp_client_session_t *session, rtsp_message_t *request, rtsp_message_t *response); + static void rtsp_client_timer_proc(apt_timer_t *timer, void *obj); +/** Get string identifier */ +static const char* rtsp_client_id_get(const rtsp_client_t *client) +{ + apt_task_t *task = apt_poller_task_base_get(client->task); + return apt_task_name_get(task); +} + /** Create RTSP client */ RTSP_DECLARE(rtsp_client_t*) rtsp_client_create( - apr_size_t max_connection_count, - apr_size_t request_timeout, - void *obj, - const rtsp_client_vtable_t *handler, - apr_pool_t *pool) + const char *id, + apr_size_t max_connection_count, + apr_size_t request_timeout, + void *obj, + const rtsp_client_vtable_t *handler, + apr_pool_t *pool) { + apt_task_t *task; apt_task_vtable_t *vtable; apt_task_msg_pool_t *msg_pool; rtsp_client_t *client; - - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create RTSP Client [%"APR_SIZE_T_FMT"]",max_connection_count); + + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create RTSP Client [%s] [%"APR_SIZE_T_FMT"]", + id, max_connection_count); client = apr_palloc(pool,sizeof(rtsp_client_t)); client->pool = pool; client->obj = obj; @@ -168,13 +183,17 @@ RTSP_DECLARE(rtsp_client_t*) rtsp_client_create( return NULL; } + task = apt_poller_task_base_get(client->task); + if(task) { + apt_task_name_set(task,id); + } + vtable = apt_poller_task_vtable_get(client->task); if(vtable) { vtable->process_msg = rtsp_client_task_msg_process; } - client->sub_pool = apt_subpool_create(pool); - client->connection_list = NULL; + APR_RING_INIT(&client->connection_list, rtsp_client_connection_t, link); client->request_timeout = (apr_uint32_t)request_timeout; return client; } @@ -182,7 +201,8 @@ RTSP_DECLARE(rtsp_client_t*) rtsp_client_create( /** Destroy RTSP client */ RTSP_DECLARE(apt_bool_t) rtsp_client_destroy(rtsp_client_t *client) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Destroy RTSP Client"); + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy RTSP Client [%s]", + rtsp_client_id_get(client)); return apt_poller_task_destroy(client->task); } @@ -302,13 +322,13 @@ RTSP_DECLARE(apt_bool_t) rtsp_client_session_request(rtsp_client_t *client, rtsp /** Create connection */ -static apt_bool_t rtsp_client_connect(rtsp_client_connection_t *connection, apt_pollset_t *pollset, const char *ip, apr_port_t port) +static apt_bool_t rtsp_client_connect(rtsp_client_t *client, rtsp_client_connection_t *connection, const char *ip, apr_port_t port) { char *local_ip = NULL; char *remote_ip = NULL; apr_sockaddr_t *l_sockaddr = NULL; apr_sockaddr_t *r_sockaddr = NULL; - + if(apr_sockaddr_info_get(&r_sockaddr,ip,APR_INET,port,0,connection->pool) != APR_SUCCESS) { return FALSE; } @@ -344,23 +364,23 @@ static apt_bool_t rtsp_client_connect(rtsp_client_connection_t *connection, apt_ connection->sock_pfd.reqevents = APR_POLLIN; connection->sock_pfd.desc.s = connection->sock; connection->sock_pfd.client_data = connection; - if(apt_pollset_add(pollset,&connection->sock_pfd) != TRUE) { + if(apt_poller_task_descriptor_add(client->task,&connection->sock_pfd) != TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add to Pollset %s",connection->id); apr_socket_close(connection->sock); connection->sock = NULL; return FALSE; } - + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Established RTSP Connection %s",connection->id); return TRUE; } /** Close connection */ -static apt_bool_t rtsp_client_connection_close(rtsp_client_connection_t *connection, apt_pollset_t *pollset) +static apt_bool_t rtsp_client_connection_close(rtsp_client_t *client, rtsp_client_connection_t *connection) { if(connection->sock) { apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close RTSP Connection %s",connection->id); - apt_pollset_remove(pollset,&connection->sock_pfd); + apt_poller_task_descriptor_remove(client->task,&connection->sock_pfd); apr_socket_close(connection->sock); connection->sock = NULL; } @@ -372,7 +392,6 @@ static apt_bool_t rtsp_client_connection_close(rtsp_client_connection_t *connect static apt_bool_t rtsp_client_connection_create(rtsp_client_t *client, rtsp_client_session_t *session) { rtsp_client_connection_t *rtsp_connection; - apt_pollset_t *pollset = apt_poller_task_pollset_get(client->task); apr_pool_t *pool = apt_pool_create(); if(!pool) { return FALSE; @@ -381,8 +400,9 @@ static apt_bool_t rtsp_client_connection_create(rtsp_client_t *client, rtsp_clie rtsp_connection = apr_palloc(pool,sizeof(rtsp_client_connection_t)); rtsp_connection->pool = pool; rtsp_connection->sock = NULL; + APR_RING_ELEM_INIT(rtsp_connection,link); - if(rtsp_client_connect(rtsp_connection,pollset,session->server_ip.buf,session->server_port) == FALSE) { + if(rtsp_client_connect(client,rtsp_connection,session->server_ip.buf,session->server_port) == FALSE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Connect to RTSP Server %s:%hu", session->server_ip.buf,session->server_port); apr_pool_destroy(pool); @@ -396,11 +416,9 @@ static apt_bool_t rtsp_client_connection_create(rtsp_client_t *client, rtsp_clie rtsp_connection->parser = rtsp_parser_create(pool); rtsp_connection->generator = rtsp_generator_create(pool); rtsp_connection->last_cseq = 0; - if(!client->connection_list) { - client->connection_list = apt_list_create(client->sub_pool); - } + rtsp_connection->client = client; - rtsp_connection->it = apt_list_push_back(client->connection_list,rtsp_connection,pool); + APR_RING_INSERT_TAIL(&client->connection_list,rtsp_connection,rtsp_client_connection_t,link); session->connection = rtsp_connection; return TRUE; } @@ -409,16 +427,11 @@ static apt_bool_t rtsp_client_connection_create(rtsp_client_t *client, rtsp_clie static apt_bool_t rtsp_client_connection_destroy(rtsp_client_connection_t *rtsp_connection) { rtsp_client_t *client = rtsp_connection->client; - apt_pollset_t *pollset = apt_poller_task_pollset_get(client->task); - apt_list_elem_remove(client->connection_list,rtsp_connection->it); - rtsp_client_connection_close(rtsp_connection,pollset); + APR_RING_REMOVE(rtsp_connection,link); + rtsp_client_connection_close(client,rtsp_connection); apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy RTSP Connection %s",rtsp_connection->id); apr_pool_destroy(rtsp_connection->pool); - if(apt_list_is_empty(client->connection_list) == TRUE) { - apr_pool_clear(client->sub_pool); - client->connection_list = NULL; - } return TRUE; } @@ -427,7 +440,7 @@ static apt_bool_t rtsp_client_session_terminate_respond(rtsp_client_t *client, r { rtsp_client_connection_t *rtsp_connection = session->connection; apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove RTSP Handle "APT_PTR_FMT,session); - apr_hash_set(rtsp_connection->handle_table,session,sizeof(session),NULL); + apr_hash_set(rtsp_connection->handle_table,session,sizeof(void*),NULL); session->term_state = TERMINATION_STATE_NONE; client->vtable->on_session_terminate_response(client,session); @@ -558,7 +571,7 @@ static apt_bool_t rtsp_client_session_request_process(rtsp_client_t *client, rts return FALSE; } apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add RTSP Handle "APT_PTR_FMT,session); - apr_hash_set(session->connection->handle_table,session,sizeof(session),session); + apr_hash_set(session->connection->handle_table,session,sizeof(void*),session); } rtsp_client_session_url_generate(session,message); @@ -567,7 +580,7 @@ static apt_bool_t rtsp_client_session_request_process(rtsp_client_t *client, rts message->header.session_id = session->id; rtsp_header_property_add(&message->header,RTSP_HEADER_FIELD_SESSION_ID,message->pool); } - + message->header.cseq = ++session->connection->last_cseq; rtsp_header_property_add(&message->header,RTSP_HEADER_FIELD_CSEQ,message->pool); @@ -594,7 +607,7 @@ static apt_bool_t rtsp_client_session_pending_requests_process(rtsp_client_t *cl if(rtsp_client_session_request_process(client,session,request) == TRUE) { return TRUE; } - + /* respond with error */ response = rtsp_response_create( request, @@ -602,7 +615,7 @@ static apt_bool_t rtsp_client_session_pending_requests_process(rtsp_client_t *cl RTSP_REASON_PHRASE_INTERNAL_SERVER_ERROR, session->pool); rtsp_client_session_response_process(client,session,request,response); - + /* process the next pending request / if any */ request = apt_list_pop_front(session->pending_request_queue); } @@ -668,7 +681,7 @@ static apt_bool_t rtsp_client_session_response_process(rtsp_client_t *client, rt const char *resource_name; if(request->start_line.common.request_line.method_id == RTSP_METHOD_SETUP && response->start_line.common.status_line.status_code == RTSP_STATUS_CODE_OK) { - + if(apr_hash_count(session->resource_table) == 0) { if(rtsp_header_property_check(&response->header,RTSP_HEADER_FIELD_SESSION_ID) == TRUE) { session->id = response->header.session_id; @@ -678,7 +691,7 @@ static apt_bool_t rtsp_client_session_response_process(rtsp_client_t *client, rt apr_hash_set(session->connection->session_table,session->id.buf,session->id.length,session); } } - + /* add resource */ resource_name = request->start_line.common.request_line.resource_name; apr_hash_set(session->resource_table,resource_name,APR_HASH_KEY_STRING,request); @@ -725,7 +738,6 @@ static apt_bool_t rtsp_client_session_terminate_raise(rtsp_client_t *client, rts } while(request); - if(session->term_state == TERMINATION_STATE_NONE) { client->vtable->on_session_terminate_event(client,session); } @@ -745,18 +757,18 @@ static apt_bool_t rtsp_client_request_cancel(rtsp_client_t *client, rtsp_client_ } request = session->active_request; - response = rtsp_response_create( request, status_code, reason, session->pool); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Cancel RTSP Request "APT_PTRSID_FMT" CSeq:%"APR_SIZE_T_FMT" [%d]", session, request->header.session_id.buf ? request->header.session_id.buf : "new", request->header.cseq, status_code); - + return rtsp_client_message_handler(session->connection, response, APT_MESSAGE_STATUS_COMPLETE); } @@ -764,12 +776,10 @@ static apt_bool_t rtsp_client_request_cancel(rtsp_client_t *client, rtsp_client_ static apt_bool_t rtsp_client_on_disconnect(rtsp_client_t *client, rtsp_client_connection_t *rtsp_connection) { rtsp_client_session_t *session; - apr_size_t remaining_handles = 0; - apr_size_t cancelled_requests = 0; - apt_pollset_t *pollset = apt_poller_task_pollset_get(client->task); + apr_size_t remaining_handles; apt_log(APT_LOG_MARK,APT_PRIO_INFO,"RTSP Peer Disconnected %s", rtsp_connection->id); - rtsp_client_connection_close(rtsp_connection,pollset); + rtsp_client_connection_close(client,rtsp_connection); /* Cancel in-progreess requests */ do { @@ -780,7 +790,6 @@ static apt_bool_t rtsp_client_on_disconnect(rtsp_client_t *client, rtsp_client_c session, RTSP_STATUS_CODE_INTERNAL_SERVER_ERROR, RTSP_REASON_PHRASE_INTERNAL_SERVER_ERROR) == TRUE) { - cancelled_requests++; apt_timer_kill(session->request_timer); } } @@ -801,7 +810,6 @@ static apt_bool_t rtsp_client_on_disconnect(rtsp_client_t *client, rtsp_client_c rtsp_client_session_terminate_raise(client,session); } } - remaining_handles = apr_hash_count(rtsp_connection->session_table); } return TRUE; @@ -819,7 +827,7 @@ static apt_bool_t rtsp_client_message_send(rtsp_client_t *client, rtsp_client_co return FALSE; } stream = &rtsp_connection->tx_stream; - + do { stream->text.length = sizeof(rtsp_connection->tx_buffer)-1; apt_text_stream_reset(stream); diff --git a/libs/unimrcp/libs/uni-rtsp/src/rtsp_header.c b/libs/unimrcp/libs/uni-rtsp/src/rtsp_header.c index de19f125f4..4aee7d7dd0 100644 --- a/libs/unimrcp/libs/uni-rtsp/src/rtsp_header.c +++ b/libs/unimrcp/libs/uni-rtsp/src/rtsp_header.c @@ -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: rtsp_header.c 1718 2010-05-31 13:12:43Z achaloyan $ + * $Id: rtsp_header.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "rtsp_header.h" diff --git a/libs/unimrcp/libs/uni-rtsp/src/rtsp_message.c b/libs/unimrcp/libs/uni-rtsp/src/rtsp_message.c index 4a8eb2a31d..59fd7168e0 100644 --- a/libs/unimrcp/libs/uni-rtsp/src/rtsp_message.c +++ b/libs/unimrcp/libs/uni-rtsp/src/rtsp_message.c @@ -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: rtsp_message.c 1648 2010-04-12 20:03:59Z achaloyan $ + * $Id: rtsp_message.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "rtsp_message.h" diff --git a/libs/unimrcp/libs/uni-rtsp/src/rtsp_server.c b/libs/unimrcp/libs/uni-rtsp/src/rtsp_server.c index e025358388..510cdca558 100644 --- a/libs/unimrcp/libs/uni-rtsp/src/rtsp_server.c +++ b/libs/unimrcp/libs/uni-rtsp/src/rtsp_server.c @@ -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,9 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: rtsp_server.c 1710 2010-05-24 17:36:19Z achaloyan $ + * $Id: rtsp_server.c 2173 2014-09-11 01:42:21Z achaloyan@gmail.com $ */ +#ifdef WIN32 +#pragma warning(disable: 4127) +#endif +#include #include #include "rtsp_server.h" #include "rtsp_stream.h" @@ -35,8 +39,8 @@ struct rtsp_server_t { apr_pool_t *pool; apt_poller_task_t *task; - apr_pool_t *sub_pool; - apt_obj_list_t *connection_list; + /** List (ring) of RTSP connections */ + APR_RING_HEAD(rtsp_server_connection_head_t, rtsp_server_connection_t) connection_list; /* Listening socket descriptor */ apr_sockaddr_t *sockaddr; @@ -49,6 +53,9 @@ struct rtsp_server_t { /** RTSP connection */ struct rtsp_server_connection_t { + /** Ring entry */ + APR_RING_ENTRY(rtsp_server_connection_t) link; + /** Memory pool */ apr_pool_t *pool; /** Client IP address */ @@ -62,8 +69,6 @@ struct rtsp_server_connection_t { /** RTSP server, connection belongs to */ rtsp_server_t *server; - /** Element of the connection list in agent */ - apt_list_elem_t *it; /** Session table (rtsp_server_session_t*) */ apr_hash_t *session_table; @@ -123,16 +128,24 @@ static apt_bool_t rtsp_server_message_send(rtsp_server_t *server, rtsp_server_co static apt_bool_t rtsp_server_listening_socket_create(rtsp_server_t *server); static void rtsp_server_listening_socket_destroy(rtsp_server_t *server); +/** Get string identifier */ +static const char* rtsp_server_id_get(const rtsp_server_t *server) +{ + apt_task_t *task = apt_poller_task_base_get(server->task); + return apt_task_name_get(task); +} /** Create RTSP server */ RTSP_DECLARE(rtsp_server_t*) rtsp_server_create( - const char *listen_ip, - apr_port_t listen_port, - apr_size_t max_connection_count, - void *obj, - const rtsp_server_vtable_t *handler, - apr_pool_t *pool) + const char *id, + const char *listen_ip, + apr_port_t listen_port, + apr_size_t max_connection_count, + void *obj, + const rtsp_server_vtable_t *handler, + apr_pool_t *pool) { + apt_task_t *task; apt_task_vtable_t *vtable; apt_task_msg_pool_t *msg_pool; rtsp_server_t *server; @@ -140,11 +153,12 @@ RTSP_DECLARE(rtsp_server_t*) rtsp_server_create( if(!listen_ip) { return NULL; } - - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create RTSP Server %s:%hu [%"APR_SIZE_T_FMT"]", - listen_ip, - listen_port, - max_connection_count); + + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create RTSP Server [%s] %s:%hu [%"APR_SIZE_T_FMT"]", + id, + listen_ip, + listen_port, + max_connection_count); server = apr_palloc(pool,sizeof(rtsp_server_t)); server->pool = pool; server->obj = obj; @@ -168,17 +182,26 @@ RTSP_DECLARE(rtsp_server_t*) rtsp_server_create( if(!server->task) { return NULL; } - + + task = apt_poller_task_base_get(server->task); + if(task) { + apt_task_name_set(task,id); + } + vtable = apt_poller_task_vtable_get(server->task); if(vtable) { vtable->destroy = rtsp_server_on_destroy; vtable->process_msg = rtsp_server_task_msg_process; } - server->sub_pool = apt_subpool_create(pool); - server->connection_list = NULL; + APR_RING_INIT(&server->connection_list, rtsp_server_connection_t, link); - rtsp_server_listening_socket_create(server); + if(rtsp_server_listening_socket_create(server) != TRUE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Listening Socket [%s] %s:%hu", + id, + listen_ip, + listen_port); + } return server; } @@ -195,7 +218,8 @@ static apt_bool_t rtsp_server_on_destroy(apt_task_t *task) /** Destroy RTSP server */ RTSP_DECLARE(apt_bool_t) rtsp_server_destroy(rtsp_server_t *server) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Destroy RTSP Server"); + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy RTSP Server [%s]", + rtsp_server_id_get(server)); return apt_poller_task_destroy(server->task); } @@ -314,7 +338,8 @@ static rtsp_server_session_t* rtsp_server_session_create(rtsp_server_t *server) /* Destroy RTSP session */ static void rtsp_server_session_destroy(rtsp_server_session_t *session) { - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy RTSP Session "APT_SID_FMT,session->id.buf); + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy RTSP Session "APT_SID_FMT, + session ? session->id.buf : "(null)"); if(session && session->pool) { apr_pool_destroy(session->pool); } @@ -329,7 +354,7 @@ static void rtsp_server_connection_destroy(rtsp_server_connection_t *rtsp_connec /* Finally terminate RTSP session */ static apt_bool_t rtsp_server_session_do_terminate(rtsp_server_t *server, rtsp_server_session_t *session) -{ +{ rtsp_server_connection_t *rtsp_connection = session->connection; if(session->active_request) { @@ -348,10 +373,12 @@ static apt_bool_t rtsp_server_session_do_terminate(rtsp_server_t *server, rtsp_s } apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove RTSP Session "APT_SID_FMT,session->id.buf); - apr_hash_set(rtsp_connection->session_table,session->id.buf,session->id.length,NULL); + if(rtsp_connection) { + apr_hash_set(rtsp_connection->session_table,session->id.buf,session->id.length,NULL); + } rtsp_server_session_destroy(session); - if(rtsp_connection && !rtsp_connection->it) { + if(rtsp_connection && !rtsp_connection->sock) { if(apr_hash_count(rtsp_connection->session_table) == 0) { rtsp_server_connection_destroy(rtsp_connection); } @@ -482,7 +509,7 @@ static apt_bool_t rtsp_server_session_request_process(rtsp_server_t *server, rts RTSP_STATUS_CODE_NOT_ACCEPTABLE, RTSP_REASON_PHRASE_NOT_ACCEPTABLE); } - + if(session->active_request) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Push RTSP Request to Queue "APT_SID_FMT,session->id.buf); apt_list_push_back(session->request_queue,message,message->pool); @@ -575,7 +602,7 @@ static apt_bool_t rtsp_server_message_send(rtsp_server_t *server, rtsp_server_co return FALSE; } stream = &rtsp_connection->tx_stream; - + do { stream->text.length = sizeof(rtsp_connection->tx_buffer)-1; apt_text_stream_reset(stream); @@ -630,13 +657,12 @@ static apt_bool_t rtsp_server_message_handler(rtsp_server_connection_t *rtsp_con return TRUE; } -/** Create listening socket and add to pollset */ +/** Create listening socket and add it to pollset */ static apt_bool_t rtsp_server_listening_socket_create(rtsp_server_t *server) { apr_status_t status; - apt_pollset_t *pollset = apt_poller_task_pollset_get(server->task); - if(!server->sockaddr || !pollset) { + if(!server->sockaddr) { return FALSE; } @@ -663,15 +689,17 @@ static apt_bool_t rtsp_server_listening_socket_create(rtsp_server_t *server) return FALSE; } + /* add listening socket to pollset */ memset(&server->listen_sock_pfd,0,sizeof(apr_pollfd_t)); server->listen_sock_pfd.desc_type = APR_POLL_SOCKET; server->listen_sock_pfd.reqevents = APR_POLLIN; server->listen_sock_pfd.desc.s = server->listen_sock; server->listen_sock_pfd.client_data = server->listen_sock; - if(apt_pollset_add(pollset, &server->listen_sock_pfd) != TRUE) { + if(apt_poller_task_descriptor_add(server->task, &server->listen_sock_pfd) != TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add Listening Socket to Pollset"); apr_socket_close(server->listen_sock); server->listen_sock = NULL; + return FALSE; } return TRUE; @@ -680,12 +708,8 @@ static apt_bool_t rtsp_server_listening_socket_create(rtsp_server_t *server) /** Remove from pollset and destroy listening socket */ static void rtsp_server_listening_socket_destroy(rtsp_server_t *server) { - apt_pollset_t *pollset = apt_poller_task_pollset_get(server->task); - if(pollset) { - apt_pollset_remove(pollset,&server->listen_sock_pfd); - } - if(server->listen_sock) { + apt_poller_task_descriptor_remove(server->task,&server->listen_sock_pfd); apr_socket_close(server->listen_sock); server->listen_sock = NULL; } @@ -699,24 +723,26 @@ static apt_bool_t rtsp_server_connection_accept(rtsp_server_t *server) char *remote_ip = NULL; apr_sockaddr_t *l_sockaddr = NULL; apr_sockaddr_t *r_sockaddr = NULL; - apt_pollset_t *pollset = apt_poller_task_pollset_get(server->task); apr_pool_t *pool = apt_pool_create(); if(!pool) { return FALSE; } - + rtsp_connection = apr_palloc(pool,sizeof(rtsp_server_connection_t)); rtsp_connection->pool = pool; rtsp_connection->sock = NULL; rtsp_connection->client_ip = NULL; + APR_RING_ELEM_INIT(rtsp_connection,link); if(apr_socket_accept(&rtsp_connection->sock,server->listen_sock,rtsp_connection->pool) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Accept RTSP Connection"); apr_pool_destroy(pool); return FALSE; } if(apr_socket_addr_get(&l_sockaddr,APR_LOCAL,rtsp_connection->sock) != APR_SUCCESS || apr_socket_addr_get(&r_sockaddr,APR_REMOTE,rtsp_connection->sock) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get RTSP Socket Address"); apr_pool_destroy(pool); return FALSE; } @@ -733,7 +759,7 @@ static apt_bool_t rtsp_server_connection_accept(rtsp_server_t *server) rtsp_connection->sock_pfd.reqevents = APR_POLLIN; rtsp_connection->sock_pfd.desc.s = rtsp_connection->sock; rtsp_connection->sock_pfd.client_data = rtsp_connection; - if(apt_pollset_add(pollset,&rtsp_connection->sock_pfd) != TRUE) { + if(apt_poller_task_descriptor_add(server->task,&rtsp_connection->sock_pfd) != TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add to Pollset %s",rtsp_connection->id); apr_socket_close(rtsp_connection->sock); apr_pool_destroy(pool); @@ -746,33 +772,24 @@ static apt_bool_t rtsp_server_connection_accept(rtsp_server_t *server) apt_text_stream_init(&rtsp_connection->tx_stream,rtsp_connection->tx_buffer,sizeof(rtsp_connection->tx_buffer)-1); rtsp_connection->parser = rtsp_parser_create(rtsp_connection->pool); rtsp_connection->generator = rtsp_generator_create(rtsp_connection->pool); - if(!server->connection_list) { - server->connection_list = apt_list_create(server->sub_pool); - } rtsp_connection->server = server; - rtsp_connection->it = apt_list_push_back(server->connection_list,rtsp_connection,rtsp_connection->pool); + APR_RING_INSERT_TAIL(&server->connection_list,rtsp_connection,rtsp_server_connection_t,link); return TRUE; } /** Close connection */ static apt_bool_t rtsp_server_connection_close(rtsp_server_t *server, rtsp_server_connection_t *rtsp_connection) { - apt_pollset_t *pollset = apt_poller_task_pollset_get(server->task); apr_size_t remaining_sessions = 0; if(!rtsp_connection || !rtsp_connection->sock) { return FALSE; } apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close RTSP Connection %s",rtsp_connection->id); - apt_pollset_remove(pollset,&rtsp_connection->sock_pfd); + apt_poller_task_descriptor_remove(server->task,&rtsp_connection->sock_pfd); apr_socket_close(rtsp_connection->sock); rtsp_connection->sock = NULL; - apt_list_elem_remove(server->connection_list,rtsp_connection->it); - rtsp_connection->it = NULL; - if(apt_list_is_empty(server->connection_list) == TRUE) { - apr_pool_clear(server->sub_pool); - server->connection_list = NULL; - } + APR_RING_REMOVE(rtsp_connection,link); remaining_sessions = apr_hash_count(rtsp_connection->session_table); if(remaining_sessions) { diff --git a/libs/unimrcp/libs/uni-rtsp/src/rtsp_start_line.c b/libs/unimrcp/libs/uni-rtsp/src/rtsp_start_line.c index 7e06a2e541..a374675af3 100644 --- a/libs/unimrcp/libs/uni-rtsp/src/rtsp_start_line.c +++ b/libs/unimrcp/libs/uni-rtsp/src/rtsp_start_line.c @@ -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: rtsp_start_line.c 1671 2010-04-28 19:50:29Z achaloyan $ + * $Id: rtsp_start_line.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "rtsp_start_line.h" diff --git a/libs/unimrcp/libs/uni-rtsp/src/rtsp_stream.c b/libs/unimrcp/libs/uni-rtsp/src/rtsp_stream.c index 845c17503b..945e7a9874 100644 --- a/libs/unimrcp/libs/uni-rtsp/src/rtsp_stream.c +++ b/libs/unimrcp/libs/uni-rtsp/src/rtsp_stream.c @@ -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: rtsp_stream.c 1648 2010-04-12 20:03:59Z achaloyan $ + * $Id: rtsp_stream.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "rtsp_stream.h" diff --git a/libs/unimrcp/libs/uni-rtsp/unirtsp.2008.vcproj b/libs/unimrcp/libs/uni-rtsp/unirtsp.2008.vcproj deleted file mode 100644 index 4189ab121e..0000000000 --- a/libs/unimrcp/libs/uni-rtsp/unirtsp.2008.vcproj +++ /dev/null @@ -1,321 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj b/libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj deleted file mode 100644 index 2d9628ec07..0000000000 --- a/libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj +++ /dev/null @@ -1,136 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - unirtsp - {504B3154-7A4F-459D-9877-B951021C3F1F} - unirtsp - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj.filters b/libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj.filters deleted file mode 100644 index 5a1581a2c3..0000000000 --- a/libs/unimrcp/libs/uni-rtsp/unirtsp.2012.vcxproj.filters +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {fd4564ef-9f34-4f23-992d-37f127e289a2} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - - - src - - - src - - - src - - - src - - - src - - - src - - - \ No newline at end of file diff --git a/libs/unimrcp/libs/uni-rtsp/unirtsp.vcproj b/libs/unimrcp/libs/uni-rtsp/unirtsp.vcproj index b7f07ad279..c2e59e70fb 100644 --- a/libs/unimrcp/libs/uni-rtsp/unirtsp.vcproj +++ b/libs/unimrcp/libs/uni-rtsp/unirtsp.vcproj @@ -41,7 +41,6 @@ /> - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - unirtsp - {504B3154-7A4F-459D-9877-B951021C3F1F} - unirtsp - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - codecs;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {504B3154-7A4F-459D-9877-B951021C3F1F} + unirtsp + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + X64 + + + ProgramDatabase + + + + + X64 + + + + + + + + + + + + + + + + + + + + + + {13deeca0-bdd4-4744-a1a2-8eb0a44df3d2} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/uni-rtsp/unirtsp.2010.vcxproj.filters b/libs/unimrcp/libs/uni-rtsp/unirtsp.vcxproj.filters similarity index 93% rename from libs/unimrcp/libs/uni-rtsp/unirtsp.2010.vcxproj.filters rename to libs/unimrcp/libs/uni-rtsp/unirtsp.vcxproj.filters index 5a1581a2c3..1a8db5806c 100644 --- a/libs/unimrcp/libs/uni-rtsp/unirtsp.2010.vcxproj.filters +++ b/libs/unimrcp/libs/uni-rtsp/unirtsp.vcxproj.filters @@ -1,56 +1,56 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {fd4564ef-9f34-4f23-992d-37f127e289a2} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - include - - - include - - - include - - - include - - - - - src - - - src - - - src - - - src - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {8ffd50c3-3b28-438d-a305-071644d5f115} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-sofiasip/Makefile.am b/libs/unimrcp/modules/mrcp-sofiasip/Makefile.am index ec0862f54d..f343037623 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/Makefile.am +++ b/libs/unimrcp/modules/mrcp-sofiasip/Makefile.am @@ -1,7 +1,6 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in -AM_CPPFLAGS = -Iinclude \ - -I$(unimrcp_srcdir)/modules/mrcp-sofiasip/include \ +AM_CPPFLAGS = -I$(top_srcdir)/modules/mrcp-sofiasip/include \ -I$(top_srcdir)/libs/mrcpv2-transport/include \ -I$(top_srcdir)/libs/mrcp-signaling/include \ -I$(top_srcdir)/libs/mrcp/include \ @@ -10,7 +9,7 @@ AM_CPPFLAGS = -Iinclude \ -I$(top_srcdir)/libs/mrcp/resources/include \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) $(UNIMRCP_SOFIA_INCLUDES) + $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_SOFIA_INCLUDES) noinst_LTLIBRARIES = libmrcpsofiasip.la @@ -19,4 +18,5 @@ include_HEADERS = include/mrcp_sdp.h \ include/mrcp_sofiasip_client_agent.h libmrcpsofiasip_la_SOURCES = src/mrcp_sdp.c \ src/mrcp_sofiasip_server_agent.c \ - src/mrcp_sofiasip_client_agent.c + src/mrcp_sofiasip_client_agent.c \ + src/mrcp_sofiasip_logger.c diff --git a/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sdp.h b/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sdp.h index 8061119c58..5c4b5c74ef 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sdp.h +++ b/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sdp.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: mrcp_sdp.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_sdp.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SDP_H @@ -32,7 +32,7 @@ APT_BEGIN_EXTERN_C MRCP_DECLARE(apr_size_t) sdp_string_generate_by_mrcp_descriptor(char *buffer, apr_size_t size, const mrcp_session_descriptor_t *descriptor, apt_bool_t offer); /** Generate MRCP descriptor by SDP session */ -MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_sdp_session(const sdp_session_t *sdp, const char *force_destination_ip, apr_pool_t *pool); +MRCP_DECLARE(apt_bool_t) mrcp_descriptor_generate_by_sdp_session(mrcp_session_descriptor_t* descriptor, const sdp_session_t *sdp, const char *force_destination_ip, apr_pool_t *pool); /** Generate SDP resource discovery string */ MRCP_DECLARE(apr_size_t) sdp_resource_discovery_string_generate(const char *ip, const char *origin, char *buffer, apr_size_t size); diff --git a/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_client_agent.h b/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_client_agent.h index da9cfdd6eb..4dd605a8cd 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_client_agent.h +++ b/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_client_agent.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: mrcp_sofiasip_client_agent.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_sofiasip_client_agent.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SOFIASIP_CLIENT_AGENT_H @@ -56,6 +56,10 @@ struct mrcp_sofia_client_config_t { apr_size_t sip_t4; /** SIP T1x64 timer */ apr_size_t sip_t1x64; + /** Print out SIP messages to the console */ + apt_bool_t tport_log; + /** Dump SIP messages to the specified file */ + char *tport_dump_file; }; /** @@ -68,6 +72,11 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sofiasip_client_agent_create(const char *id */ MRCP_DECLARE(mrcp_sofia_client_config_t*) mrcp_sofiasip_client_config_alloc(apr_pool_t *pool); +/** + * Initialize Sofia-SIP logger. + */ +MRCP_DECLARE(apt_bool_t) mrcp_sofiasip_client_logger_init(const char *name, const char *level_str, apt_bool_t redirect); + APT_END_EXTERN_C #endif /* MRCP_SOFIASIP_CLIENT_AGENT_H */ diff --git a/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_server_agent.h b/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_server_agent.h index 7876d59f68..81302b4188 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_server_agent.h +++ b/libs/unimrcp/modules/mrcp-sofiasip/include/mrcp_sofiasip_server_agent.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: mrcp_sofiasip_server_agent.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_sofiasip_server_agent.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_SOFIASIP_SERVER_AGENT_H @@ -59,6 +59,10 @@ struct mrcp_sofia_server_config_t { apr_size_t sip_t4; /** SIP T1x64 timer */ apr_size_t sip_t1x64; + /** Print out SIP messages to the console */ + apt_bool_t tport_log; + /** Dump SIP messages to the specified file */ + char *tport_dump_file; }; /** @@ -71,6 +75,11 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sofiasip_server_agent_create(const char *id */ MRCP_DECLARE(mrcp_sofia_server_config_t*) mrcp_sofiasip_server_config_alloc(apr_pool_t *pool); +/** + * Initialize Sofia-SIP logger. + */ +MRCP_DECLARE(apt_bool_t) mrcp_sofiasip_server_logger_init(const char *name, const char *level_str, apt_bool_t redirect); + APT_END_EXTERN_C #endif /* MRCP_SOFIASIP_SERVER_AGENT_H */ diff --git a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2008.vcproj b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2008.vcproj deleted file mode 100644 index 5b10a418b3..0000000000 --- a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2008.vcproj +++ /dev/null @@ -1,293 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj deleted file mode 100644 index eed2e6e906..0000000000 --- a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2012.vcxproj +++ /dev/null @@ -1,142 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpsofiasip - {746F3632-5BB2-4570-9453-31D6D58A7D8E} - mrcpsofiasip - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - ProgramDatabase - - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - {70a49bc2-7500-41d0-b75d-edcc5be987a0} - - - - - - diff --git a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcproj b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcproj index d45a60f869..20f9ce8e3a 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcproj +++ b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcproj @@ -256,6 +256,10 @@ RelativePath=".\include\mrcp_sofiasip_server_agent.h" > + + + + diff --git a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2010.vcxproj b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcxproj similarity index 62% rename from libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2010.vcxproj rename to libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcxproj index b3931497c7..037cc3685e 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2010.vcxproj +++ b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcxproj @@ -1,138 +1,147 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpsofiasip - {746F3632-5BB2-4570-9453-31D6D58A7D8E} - mrcpsofiasip - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - ProgramDatabase - - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - {70a49bc2-7500-41d0-b75d-edcc5be987a0} - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {746F3632-5BB2-4570-9453-31D6D58A7D8E} + mrcpsofiasip + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + + + include;%(AdditionalIncludeDirectories) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + {12a49562-bab9-43a3-a21d-15b60bbb4c31} + false + + + {a9edac04-6a5f-4ba7-bc0d-cce7b255b6ea} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2010.vcxproj.filters b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcxproj.filters similarity index 86% rename from libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2010.vcxproj.filters rename to libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcxproj.filters index d2157eea88..d0579e36d8 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.2010.vcxproj.filters +++ b/libs/unimrcp/modules/mrcp-sofiasip/mrcpsofiasip.vcxproj.filters @@ -1,35 +1,38 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {6e92b598-880e-4fe5-88fb-f69df8e06a57} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - - - src - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {5256b9c6-18be-48fc-aaa3-8e2c17df7f8d} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + + + src + + + src + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c index 23a1efe8d9..ab1340bf39 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c +++ b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c @@ -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: mrcp_sdp.c 1647 2010-04-12 19:34:53Z achaloyan $ + * $Id: mrcp_sdp.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -23,6 +23,7 @@ #include "mrcp_session_descriptor.h" #include "mrcp_control_descriptor.h" #include "mpf_rtp_attribs.h" +#include "mpf_rtp_pt.h" #include "apt_text_stream.h" #include "apt_log.h" @@ -83,18 +84,15 @@ MRCP_DECLARE(apr_size_t) sdp_string_generate_by_mrcp_descriptor(char *buffer, ap } /** Generate MRCP descriptor by SDP session */ -MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_sdp_session(const sdp_session_t *sdp, const char *force_destination_ip, apr_pool_t *pool) +MRCP_DECLARE(apt_bool_t) mrcp_descriptor_generate_by_sdp_session(mrcp_session_descriptor_t* descriptor, const sdp_session_t *sdp, const char *force_destination_ip, apr_pool_t *pool) { sdp_media_t *sdp_media; - mrcp_session_descriptor_t *descriptor; if(!sdp) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid SDP Message"); - return NULL; + return FALSE; } - descriptor = mrcp_session_descriptor_create(pool); - if(force_destination_ip) { apt_string_assign(&descriptor->ip,force_destination_ip,pool); } @@ -132,37 +130,43 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_sdp_session break; } } - return descriptor; + return TRUE; } - /** Generate SDP media by RTP media descriptor */ static apr_size_t sdp_rtp_media_generate(char *buffer, apr_size_t size, const mrcp_session_descriptor_t *descriptor, const mpf_rtp_media_descriptor_t *audio_media) { apr_size_t offset = 0; - int i; - mpf_codec_descriptor_t *codec_descriptor; - apr_array_header_t *descriptor_arr = audio_media->codec_list.descriptor_arr; - if(!descriptor_arr) { - return 0; - } - offset += snprintf(buffer+offset,size-offset, - "m=audio %d RTP/AVP", - audio_media->state == MPF_MEDIA_ENABLED ? audio_media->port : 0); - for(i=0; inelts; i++) { - codec_descriptor = &APR_ARRAY_IDX(descriptor_arr,i,mpf_codec_descriptor_t); - if(codec_descriptor->enabled == TRUE) { - offset += snprintf(buffer+offset,size-offset," %d", codec_descriptor->payload_type); - } - } - offset += snprintf(buffer+offset,size-offset,"\r\n"); - if(descriptor->ip.length && audio_media->ip.length && - apt_string_compare(&descriptor->ip,&audio_media->ip) != TRUE) { - const char *media_ip = audio_media->ext_ip.buf ? audio_media->ext_ip.buf : audio_media->ip.buf; - offset += sprintf(buffer+offset,"c=IN IP4 %s\r\n",media_ip); - } if(audio_media->state == MPF_MEDIA_ENABLED) { - const apt_str_t *direction_str = mpf_rtp_direction_str_get(audio_media->direction); + int codec_count = 0; + int i; + mpf_codec_descriptor_t *codec_descriptor; + apr_array_header_t *descriptor_arr = audio_media->codec_list.descriptor_arr; + const apt_str_t *direction_str; + if(!descriptor_arr) { + return 0; + } + + offset += snprintf(buffer+offset,size-offset,"m=audio %d RTP/AVP",audio_media->port); + for(i=0; inelts; i++) { + codec_descriptor = &APR_ARRAY_IDX(descriptor_arr,i,mpf_codec_descriptor_t); + if(codec_descriptor->enabled == TRUE) { + offset += snprintf(buffer+offset,size-offset," %d",codec_descriptor->payload_type); + codec_count++; + } + } + if(!codec_count){ + /* SDP m line should have at least one media format listed; use a reserved RTP payload type */ + offset += snprintf(buffer+offset,size-offset," %d",RTP_PT_RESERVED); + } + offset += snprintf(buffer+offset,size-offset,"\r\n"); + + if(descriptor->ip.length && audio_media->ip.length && + apt_string_compare(&descriptor->ip,&audio_media->ip) != TRUE) { + const char *media_ip = audio_media->ext_ip.buf ? audio_media->ext_ip.buf : audio_media->ip.buf; + offset += snprintf(buffer+offset,size-offset,"c=IN IP4 %s\r\n",media_ip); + } + for(i=0; inelts; i++) { codec_descriptor = &APR_ARRAY_IDX(descriptor_arr,i,mpf_codec_descriptor_t); if(codec_descriptor->enabled == TRUE && codec_descriptor->name.buf) { @@ -177,6 +181,8 @@ static apr_size_t sdp_rtp_media_generate(char *buffer, apr_size_t size, const mr } } } + + direction_str = mpf_rtp_direction_str_get(audio_media->direction); if(direction_str) { offset += snprintf(buffer+offset,size-offset,"a=%s\r\n",direction_str->buf); } @@ -185,6 +191,10 @@ static apr_size_t sdp_rtp_media_generate(char *buffer, apr_size_t size, const mr offset += snprintf(buffer+offset,size-offset,"a=ptime:%hu\r\n",audio_media->ptime); } } + else { + offset += snprintf(buffer+offset,size-offset,"m=audio 0 RTP/AVP %d\r\n",RTP_PT_RESERVED); + } + offset += snprintf(buffer+offset,size-offset,"a=mid:%"APR_SIZE_T_FMT"\r\n",audio_media->mid); return offset; } @@ -225,7 +235,7 @@ static apr_size_t sdp_control_media_generate(char *buffer, apr_size_t size, cons } else { /* answer */ if(control_media->port) { - offset += sprintf(buffer+offset, + offset += snprintf(buffer+offset,size-offset, "m=application %d %s 1\r\n" "a=setup:%s\r\n" "a=connection:%s\r\n" @@ -238,7 +248,7 @@ static apr_size_t sdp_control_media_generate(char *buffer, apr_size_t size, cons control_media->resource_name.buf); } else { - offset += sprintf(buffer+offset, + offset += snprintf(buffer+offset,size-offset, "m=application %d %s 1\r\n" "a=channel:%s@%s\r\n", control_media->port, @@ -252,7 +262,6 @@ static apr_size_t sdp_control_media_generate(char *buffer, apr_size_t size, cons offset += snprintf(buffer+offset,size-offset, "a=cmid:%"APR_SIZE_T_FMT"\r\n", APR_ARRAY_IDX(control_media->cmid_arr,i,apr_size_t)); - } return offset; diff --git a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_client_agent.c b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_client_agent.c index 6ef4199fbe..71e9da0375 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_client_agent.c +++ b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_client_agent.c @@ -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: mrcp_sofiasip_client_agent.c 1799 2011-05-12 02:32:32Z achaloyan $ + * $Id: mrcp_sofiasip_client_agent.c 2225 2014-11-12 00:45:19Z achaloyan@gmail.com $ */ typedef struct mrcp_sofia_agent_t mrcp_sofia_agent_t; @@ -26,6 +26,7 @@ typedef struct mrcp_sofia_session_t mrcp_sofia_session_t; #include #include #include +#include #include #undef strcasecmp #undef strncasecmp @@ -56,6 +57,7 @@ struct mrcp_sofia_session_t { su_home_t *home; nua_handle_t *nh; + enum nua_callstate nua_state; apt_bool_t terminate_requested; mrcp_session_descriptor_t *descriptor; @@ -92,6 +94,7 @@ static void mrcp_sofia_event_callback( nua_event_t nua_event, sip_t const *sip, tagi_t tags[]); +apt_bool_t mrcp_sofiasip_log_init(const char *name, const char *level_str, apt_bool_t redirect); /** Create Sofia-SIP Signaling Agent */ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sofiasip_client_agent_create(const char *id, mrcp_sofia_client_config_t *config, apr_pool_t *pool) @@ -100,7 +103,7 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sofiasip_client_agent_create(const char *id apt_task_vtable_t *vtable; mrcp_sofia_agent_t *sofia_agent; sofia_agent = apr_palloc(pool,sizeof(mrcp_sofia_agent_t)); - sofia_agent->sig_agent = mrcp_signaling_agent_create(id,sofia_agent,MRCP_VERSION_2,pool); + sofia_agent->sig_agent = mrcp_signaling_agent_create(id,sofia_agent,pool); sofia_agent->sig_agent->create_client_session = mrcp_sofia_session_create; sofia_agent->root = NULL; sofia_agent->nua = NULL; @@ -143,19 +146,34 @@ MRCP_DECLARE(mrcp_sofia_client_config_t*) mrcp_sofiasip_client_config_alloc(apr_ config->sip_t2 = 0; config->sip_t4 = 0; config->sip_t1x64 = 0; + + config->tport_log = FALSE; + config->tport_dump_file = NULL; + return config; } +MRCP_DECLARE(apt_bool_t) mrcp_sofiasip_client_logger_init(const char *name, const char *level_str, apt_bool_t redirect) +{ + return mrcp_sofiasip_log_init(name,level_str,redirect); +} + static apt_bool_t mrcp_sofia_config_validate(mrcp_sofia_agent_t *sofia_agent, mrcp_sofia_client_config_t *config, apr_pool_t *pool) { - const char *local_ip = config->ext_ip ? config->ext_ip : config->local_ip; if(!config->local_ip) { return FALSE; } sofia_agent->config = config; - sofia_agent->sip_contact_str = apr_psprintf(pool,"sip:%s:%hu", local_ip, config->local_port); - sofia_agent->sip_from_str = apr_psprintf(pool,"sip:%s:%hu", local_ip, config->local_port); + if(config->ext_ip) { + /* Use external IP address in Contact and From headers, if behind NAT */ + sofia_agent->sip_contact_str = apr_psprintf(pool,"sip:%s:%hu", config->ext_ip, config->local_port); + sofia_agent->sip_from_str = apr_psprintf(pool,"sip:%s:%hu", config->ext_ip, config->local_port); + } + else { + sofia_agent->sip_contact_str = NULL; /* Let Sofia-SIP implicitly set Contact header by default */ + sofia_agent->sip_from_str = apr_psprintf(pool,"sip:%s:%hu", config->local_ip, config->local_port); + } if(config->transport) { sofia_agent->sip_bind_str = apr_psprintf(pool,"sip:%s:%hu;transport=%s", @@ -189,6 +207,8 @@ static void mrcp_sofia_task_initialize(apt_task_t *task) mrcp_sofia_event_callback, /* Callback for processing events */ sofia_agent, /* Additional data to pass to callback */ NUTAG_URL(sofia_agent->sip_bind_str), /* Address to bind to */ + TAG_IF(sofia_config->tport_log == TRUE,TPTAG_LOG(1)), /* Print out SIP messages to the console */ + TAG_IF(sofia_config->tport_dump_file,TPTAG_DUMP(sofia_config->tport_dump_file)), /* Dump SIP messages to the file */ TAG_END()); /* Last tag should always finish the sequence */ if(sofia_agent->nua) { nua_set_params( @@ -202,6 +222,11 @@ static void mrcp_sofia_task_initialize(apt_task_t *task) SIPTAG_USER_AGENT_STR(sofia_config->user_agent_name), TAG_END()); } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create NUA [%s] %s", + apt_task_name_get(task), + sofia_agent->sip_bind_str); + } } static apt_bool_t mrcp_sofia_task_run(apt_task_t *task) @@ -220,7 +245,7 @@ static apt_bool_t mrcp_sofia_task_run(apt_task_t *task) sofia_agent->root = NULL; su_deinit(); - apt_task_child_terminate(task); + apt_task_terminate_request_process(task); return TRUE; } @@ -228,7 +253,8 @@ static apt_bool_t mrcp_sofia_task_terminate(apt_task_t *task) { mrcp_sofia_agent_t *sofia_agent = apt_task_object_get(task); if(sofia_agent->nua) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Send Shutdown Signal to NUA"); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Send Shutdown Signal to NUA [%s]", + apt_task_name_get(task)); nua_shutdown(sofia_agent->nua); } return TRUE; @@ -245,6 +271,10 @@ static apt_bool_t mrcp_sofia_session_create(mrcp_session_t *session, mrcp_sig_se mrcp_sofia_session_t *sofia_session; session->request_vtable = &session_request_vtable; + if(!sofia_agent->nua) { + return FALSE; + } + sofia_session = apr_palloc(session->pool,sizeof(mrcp_sofia_session_t)); sofia_session->mutex = NULL; sofia_session->home = su_home_new(sizeof(*sofia_session->home)); @@ -254,7 +284,7 @@ static apt_bool_t mrcp_sofia_session_create(mrcp_session_t *session, mrcp_sig_se sofia_session->descriptor = NULL; session->obj = sofia_session; - if(settings->user_name && settings->user_name != '\0') { + if(settings->user_name && *settings->user_name != '\0') { sofia_session->sip_to_str = apr_psprintf(session->pool,"sip:%s@%s:%hu", settings->user_name, settings->server_ip, @@ -271,15 +301,16 @@ static apt_bool_t mrcp_sofia_session_create(mrcp_session_t *session, mrcp_sig_se sofia_session, SIPTAG_TO_STR(sofia_session->sip_to_str), SIPTAG_FROM_STR(sofia_agent->sip_from_str), - SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str), + TAG_IF(sofia_agent->sip_contact_str,SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str)), TAG_IF(settings->feature_tags,SIPTAG_ACCEPT_CONTACT_STR(settings->feature_tags)), TAG_END()); + sofia_session->nua_state = nua_callstate_init; apr_thread_mutex_create(&sofia_session->mutex,APR_THREAD_MUTEX_DEFAULT,session->pool); return TRUE; } -static apt_bool_t mrcp_sofia_session_destroy(mrcp_sofia_session_t *sofia_session) +static apt_bool_t mrcp_sofia_session_cleanup(mrcp_sofia_session_t *sofia_session) { if(sofia_session->mutex) { apr_thread_mutex_destroy(sofia_session->mutex); @@ -306,7 +337,7 @@ static apt_bool_t mrcp_sofia_session_unref(mrcp_sofia_session_t *sofia_session) static apt_bool_t mrcp_sofia_session_offer(mrcp_session_t *session, mrcp_session_descriptor_t *descriptor) { char sdp_str[2048]; - char *local_sdp_str = NULL; + const char *local_sdp_str = NULL; apt_bool_t res = FALSE; mrcp_sofia_session_t *sofia_session = session->obj; if(!sofia_session) { @@ -359,7 +390,7 @@ static apt_bool_t mrcp_sofia_session_terminate_request(mrcp_session_t *session) apr_thread_mutex_unlock(sofia_session->mutex); if(sofia_session->terminate_requested == FALSE) { - mrcp_sofia_session_destroy(sofia_session); + mrcp_sofia_session_cleanup(sofia_session); mrcp_session_terminate_response(session); } return TRUE; @@ -391,35 +422,34 @@ static void mrcp_sofia_on_session_ready( tagi_t tags[]) { mrcp_session_t *session = sofia_session->session; - if(session) { - const char *local_sdp_str = NULL, *remote_sdp_str = NULL; - mrcp_session_descriptor_t *descriptor = NULL; + const char *remote_sdp_str = NULL; + mrcp_session_descriptor_t *descriptor = mrcp_session_descriptor_create(session->pool); + descriptor->response_code = status; - tl_gets(tags, - SOATAG_LOCAL_SDP_STR_REF(local_sdp_str), - SOATAG_REMOTE_SDP_STR_REF(remote_sdp_str), - TAG_END()); + tl_gets(tags, + SOATAG_REMOTE_SDP_STR_REF(remote_sdp_str), + TAG_END()); - if(remote_sdp_str) { - sdp_parser_t *parser = NULL; - sdp_session_t *sdp = NULL; - const char *force_destination_ip = NULL; - apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->log_obj,"Remote SDP "APT_NAMESID_FMT"\n%s", - session->name, - MRCP_SESSION_SID(session), - remote_sdp_str); + if(remote_sdp_str) { + sdp_parser_t *parser = NULL; + sdp_session_t *sdp = NULL; + const char *force_destination_ip = NULL; + apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->log_obj,"Remote SDP "APT_NAMESID_FMT"\n%s", + session->name, + MRCP_SESSION_SID(session), + remote_sdp_str); - parser = sdp_parse(sofia_session->home,remote_sdp_str,(int)strlen(remote_sdp_str),0); - sdp = sdp_session(parser); - if(sofia_session->sip_settings->force_destination == TRUE) { - force_destination_ip = sofia_session->sip_settings->server_ip; - } - descriptor = mrcp_descriptor_generate_by_sdp_session(sdp,force_destination_ip,session->pool); - sdp_parser_free(parser); + parser = sdp_parse(sofia_session->home,remote_sdp_str,(int)strlen(remote_sdp_str),0); + sdp = sdp_session(parser); + if(sofia_session->sip_settings->force_destination == TRUE) { + force_destination_ip = sofia_session->sip_settings->server_ip; } - mrcp_session_answer(session,descriptor); + mrcp_descriptor_generate_by_sdp_session(descriptor,sdp,force_destination_ip,session->pool); + sdp_parser_free(parser); } + + mrcp_session_answer(session,descriptor); } static void mrcp_sofia_on_session_redirect( @@ -436,11 +466,11 @@ static void mrcp_sofia_on_session_redirect( return; } sip_contact = sip->sip_contact; - if(!sip_contact || !sip_contact->m_url) { + if(!sip_contact) { return; } - if(sip_contact->m_url->url_user && sip_contact->m_url->url_user != '\0') { + if(sip_contact->m_url->url_user && *sip_contact->m_url->url_user != '\0') { sofia_session->sip_to_str = apr_psprintf(session->pool,"sip:%s@%s:%s", sip_contact->m_url->url_user, sip_contact->m_url->url_host, @@ -470,7 +500,7 @@ static void mrcp_sofia_on_session_redirect( sofia_session, SIPTAG_TO_STR(sofia_session->sip_to_str), SIPTAG_FROM_STR(sofia_agent->sip_from_str), - SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str), + TAG_IF(sofia_agent->sip_contact_str,SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str)), TAG_END()); apr_thread_mutex_unlock(sofia_session->mutex); @@ -486,24 +516,31 @@ static void mrcp_sofia_on_session_terminate( sip_t const *sip, tagi_t tags[]) { - mrcp_session_t *session = sofia_session->session; - if(session) { - apt_bool_t terminate_requested; - - apr_thread_mutex_lock(sofia_session->mutex); - terminate_requested = sofia_session->terminate_requested; - session = sofia_session->session; - mrcp_sofia_session_unref(sofia_session); - apr_thread_mutex_unlock(sofia_session->mutex); + mrcp_session_t *session; + apt_bool_t terminate_requested; - if(terminate_requested == TRUE) { - mrcp_sofia_session_destroy(sofia_session); - mrcp_session_terminate_response(session); - } - else { - mrcp_session_terminate_event(session); - } + apr_thread_mutex_lock(sofia_session->mutex); + terminate_requested = sofia_session->terminate_requested; + session = sofia_session->session; + mrcp_sofia_session_unref(sofia_session); + apr_thread_mutex_unlock(sofia_session->mutex); + + if(terminate_requested == TRUE) { + sofia_session->nua_state = nua_callstate_terminated; + mrcp_sofia_session_cleanup(sofia_session); + mrcp_session_terminate_response(session); + return; } + + if(sofia_session->nua_state == nua_callstate_ready) { + mrcp_session_terminate_event(session); + } + else { + mrcp_session_descriptor_t *descriptor = mrcp_session_descriptor_create(session->pool); + descriptor->response_code = status; + mrcp_session_answer(session,descriptor); + } + sofia_session->nua_state = nua_callstate_terminated; } static void mrcp_sofia_on_state_change( @@ -514,23 +551,28 @@ static void mrcp_sofia_on_state_change( sip_t const *sip, tagi_t tags[]) { - int ss_state = nua_callstate_init; + int nua_state = nua_callstate_init; tl_gets(tags, - NUTAG_CALLSTATE_REF(ss_state), + NUTAG_CALLSTATE_REF(nua_state), TAG_END()); - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"SIP Call State %s [%s]", - sofia_session ? sofia_session->session->name : "", - nua_callstate_name(ss_state)); - - switch(ss_state) { - case nua_callstate_ready: - mrcp_sofia_on_session_ready(status,sofia_agent,nh,sofia_session,sip,tags); - break; - case nua_callstate_terminated: - mrcp_sofia_on_session_terminate(status,sofia_agent,nh,sofia_session,sip,tags); - break; + if(!sofia_session || !sofia_session->session) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"SIP Call State [%s]", nua_callstate_name(nua_state)); + return; } + apt_obj_log(APT_LOG_MARK,APT_PRIO_NOTICE,sofia_session->session->log_obj,"SIP Call State %s [%s]", + sofia_session->session->name, + nua_callstate_name(nua_state)); + + if(nua_state == nua_callstate_terminated) { + mrcp_sofia_on_session_terminate(status,sofia_agent,nh,sofia_session,sip,tags); + return; + } + + if(nua_state == nua_callstate_ready) { + mrcp_sofia_on_session_ready(status,sofia_agent,nh,sofia_session,sip,tags); + } + sofia_session->nua_state = nua_state; } static void mrcp_sofia_on_resource_discover( @@ -544,7 +586,8 @@ static void mrcp_sofia_on_resource_discover( mrcp_session_t *session = sofia_session->session; if(session) { const char *remote_sdp_str = NULL; - mrcp_session_descriptor_t *descriptor = NULL; + mrcp_session_descriptor_t *descriptor = mrcp_session_descriptor_create(session->pool); + descriptor->response_code = status; if(sip->sip_payload) { remote_sdp_str = sip->sip_payload->pl_data; @@ -559,7 +602,7 @@ static void mrcp_sofia_on_resource_discover( parser = sdp_parse(sofia_session->home,remote_sdp_str,(int)strlen(remote_sdp_str),0); sdp = sdp_session(parser); - descriptor = mrcp_descriptor_generate_by_sdp_session(sdp,NULL,session->pool); + mrcp_descriptor_generate_by_sdp_session(descriptor,sdp,NULL,session->pool); sdp_parser_free(parser); } @@ -579,8 +622,11 @@ static void mrcp_sofia_event_callback( sip_t const *sip, tagi_t tags[]) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive SIP Event [%s] Status %d %s", - nua_event_name(nua_event),status,phrase); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive SIP Event [%s] Status %d %s [%s]", + nua_event_name(nua_event), + status, + phrase, + sofia_agent->sig_agent->id); switch(nua_event) { case nua_i_state: diff --git a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_logger.c b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_logger.c new file mode 100644 index 0000000000..49590e2fa8 --- /dev/null +++ b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_logger.c @@ -0,0 +1,92 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Id: mrcp_sofiasip_logger.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ + */ + +#include +#include +#include +#include "apt_log.h" + +SOFIAPUBVAR su_log_t tport_log[]; /* Transport event debug */ +SOFIAPUBVAR su_log_t nea_log[]; /* Event engine debug */ +SOFIAPUBVAR su_log_t nta_log[]; /* Transaction engine debug */ +SOFIAPUBVAR su_log_t nua_log[]; /* User Agent engine debug */ +SOFIAPUBVAR su_log_t soa_log[]; /* SDP Offer/Answer engine debug */ +SOFIAPUBVAR su_log_t su_log_default[]; /* Default debug */ + +static void mrcp_sofiasip_log(void *stream, char const *format, va_list arg_ptr) +{ + if(format) { + /* use generic vsnprintf() since apr_vformatter doesn't support + the format %p widely used by SofiaSIP. */ + char buf[4096]; + int len = vsnprintf(buf, sizeof(buf), format, arg_ptr); + if(len <= 0) + return; + if(buf[len-1] == '\n') { + /* remove trailing '\n' since apt logger appends it anyway */ + len--; + buf[len] = '\0'; + } + apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "%.*s", len, buf); + } +} + +static su_log_t* mrcp_sofiasip_logger_get(const char *name) +{ + if (!strcasecmp(name,"tport")) + return tport_log; + else if (!strcasecmp(name,"nea")) + return nea_log; + else if (!strcasecmp(name,"nta")) + return nta_log; + else if (!strcasecmp(name,"nua")) + return nua_log; + else if (!strcasecmp(name,"soa")) + return soa_log; + else if (!strcasecmp(name,"default")) + return su_log_default; + return NULL; +} + +apt_bool_t mrcp_sofiasip_log_init(const char *name, const char *level_str, apt_bool_t redirect) +{ + su_log_t *logger = mrcp_sofiasip_logger_get(name); + if(!logger) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown SofiaSIP Logger <%s>",name); + return FALSE; + } + + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Init SofiaSIP Logger [%s] level:%s redirect:%d", + name, level_str, redirect); + su_log_init(logger); + + if(redirect == TRUE) { + su_log_redirect(logger, mrcp_sofiasip_log, NULL); + } + + if(level_str) { + int level = atoi(level_str); + if(level >=0 && level < 10) { + su_log_set_level(logger, level); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown SofiaSIP Log Level [%s]: must be in range [0..9]",level_str); + } + } + return TRUE; +} diff --git a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_server_agent.c b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_server_agent.c index e094078a24..427b3f9c57 100644 --- a/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_server_agent.c +++ b/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sofiasip_server_agent.c @@ -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: mrcp_sofiasip_server_agent.c 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_sofiasip_server_agent.c 2221 2014-11-11 02:44:03Z achaloyan@gmail.com $ */ typedef struct mrcp_sofia_agent_t mrcp_sofia_agent_t; @@ -26,6 +26,7 @@ typedef struct mrcp_sofia_session_t mrcp_sofia_session_t; #include #include #include +#include #include #undef strcasecmp #undef strncasecmp @@ -65,7 +66,9 @@ static apt_bool_t mrcp_sofia_on_session_terminate(mrcp_session_t *session); static const mrcp_session_response_vtable_t session_response_vtable = { mrcp_sofia_on_session_answer, - mrcp_sofia_on_session_terminate + mrcp_sofia_on_session_terminate, + NULL /* mrcp_sofia_on_session_control */, + NULL /* mrcp_sofia_on_session_discover */ }; static apt_bool_t mrcp_sofia_config_validate(mrcp_sofia_agent_t *sofia_agent, mrcp_sofia_server_config_t *config, apr_pool_t *pool); @@ -80,6 +83,7 @@ static void mrcp_sofia_event_callback( nua_event_t nua_event, sip_t const *sip, tagi_t tags[]); +apt_bool_t mrcp_sofiasip_log_init(const char *name, const char *level_str, apt_bool_t redirect); /** Create Sofia-SIP Signaling Agent */ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sofiasip_server_agent_create(const char *id, mrcp_sofia_server_config_t *config, apr_pool_t *pool) @@ -88,7 +92,7 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_sofiasip_server_agent_create(const char *id apt_task_vtable_t *vtable; mrcp_sofia_agent_t *sofia_agent; sofia_agent = apr_palloc(pool,sizeof(mrcp_sofia_agent_t)); - sofia_agent->sig_agent = mrcp_signaling_agent_create(id,sofia_agent,MRCP_VERSION_2,pool); + sofia_agent->sig_agent = mrcp_signaling_agent_create(id,sofia_agent,pool); sofia_agent->config = config; sofia_agent->root = NULL; sofia_agent->nua = NULL; @@ -130,14 +134,26 @@ MRCP_DECLARE(mrcp_sofia_server_config_t*) mrcp_sofiasip_server_config_alloc(apr_ config->sip_t2 = 0; config->sip_t4 = 0; config->sip_t1x64 = 0; + + config->tport_log = FALSE; + config->tport_dump_file = NULL; + return config; } +MRCP_DECLARE(apt_bool_t) mrcp_sofiasip_server_logger_init(const char *name, const char *level_str, apt_bool_t redirect) +{ + return mrcp_sofiasip_log_init(name,level_str,redirect); +} + static apt_bool_t mrcp_sofia_config_validate(mrcp_sofia_agent_t *sofia_agent, mrcp_sofia_server_config_t *config, apr_pool_t *pool) { - const char *local_ip = config->ext_ip ? config->ext_ip : config->local_ip; sofia_agent->config = config; - sofia_agent->sip_contact_str = apr_psprintf(pool,"sip:%s:%hu",local_ip,config->local_port); + sofia_agent->sip_contact_str = NULL; /* Let Sofia-SIP implicitly set Contact header by default */ + if(config->ext_ip) { + /* Use external IP address in Contact header, if behind NAT */ + sofia_agent->sip_contact_str = apr_psprintf(pool,"sip:%s:%hu",config->ext_ip,config->local_port); + } if(config->transport) { sofia_agent->sip_bind_str = apr_psprintf(pool,"sip:%s:%hu;transport=%s", config->local_ip, @@ -170,6 +186,8 @@ static void mrcp_sofia_task_initialize(apt_task_t *task) mrcp_sofia_event_callback, /* Callback for processing events */ sofia_agent, /* Additional data to pass to callback */ NUTAG_URL(sofia_agent->sip_bind_str), /* Address to bind to */ + TAG_IF(sofia_config->tport_log == TRUE,TPTAG_LOG(1)), /* Print out SIP messages to the console */ + TAG_IF(sofia_config->tport_dump_file,TPTAG_DUMP(sofia_config->tport_dump_file)), /* Dump SIP messages to the file */ TAG_END()); /* Last tag should always finish the sequence */ if(sofia_agent->nua) { nua_set_params( @@ -183,6 +201,11 @@ static void mrcp_sofia_task_initialize(apt_task_t *task) SIPTAG_USER_AGENT_STR(sofia_config->user_agent_name), TAG_END()); } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create NUA [%s] %s", + apt_task_name_get(task), + sofia_agent->sip_bind_str); + } } static apt_bool_t mrcp_sofia_task_run(apt_task_t *task) @@ -201,7 +224,7 @@ static apt_bool_t mrcp_sofia_task_run(apt_task_t *task) sofia_agent->root = NULL; su_deinit(); - apt_task_child_terminate(task); + apt_task_terminate_request_process(task); return TRUE; } @@ -209,7 +232,8 @@ static apt_bool_t mrcp_sofia_task_terminate(apt_task_t *task) { mrcp_sofia_agent_t *sofia_agent = apt_task_object_get(task); if(sofia_agent->nua) { - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Send Shutdown Signal to NUA"); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Send Shutdown Signal to NUA [%s]", + apt_task_name_get(task)); nua_shutdown(sofia_agent->nua); } return TRUE; @@ -266,7 +290,7 @@ static apt_bool_t mrcp_sofia_on_session_answer(mrcp_session_t *session, mrcp_ses if(descriptor->status != MRCP_SESSION_STATUS_OK) { int status = sip_status_get(descriptor->status); nua_respond(sofia_session->nh, status, sip_status_phrase(status), - SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str), + TAG_IF(sofia_agent->sip_contact_str,SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str)), TAG_END()); return TRUE; } @@ -284,7 +308,7 @@ static apt_bool_t mrcp_sofia_on_session_answer(mrcp_session_t *session, mrcp_ses } nua_respond(sofia_session->nh, SIP_200_OK, - SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str), + TAG_IF(sofia_agent->sip_contact_str,SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str)), TAG_IF(local_sdp_str,SOATAG_USER_SDP_STR(local_sdp_str)), SOATAG_AUDIO_AUX("telephone-event"), NUTAG_AUTOANSWER(0), @@ -319,19 +343,10 @@ static void mrcp_sofia_on_call_receive(mrcp_sofia_agent_t *sofia_agent, sip_t const *sip, tagi_t tags[]) { - int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0; - const char *local_sdp_str = NULL, *remote_sdp_str = NULL; - mrcp_session_descriptor_t *descriptor = NULL; + apt_bool_t status = FALSE; + const char *remote_sdp_str = NULL; + mrcp_session_descriptor_t *descriptor; - tl_gets(tags, - NUTAG_OFFER_RECV_REF(offer_recv), - NUTAG_ANSWER_RECV_REF(answer_recv), - NUTAG_OFFER_SENT_REF(offer_sent), - NUTAG_ANSWER_SENT_REF(answer_sent), - SOATAG_LOCAL_SDP_STR_REF(local_sdp_str), - SOATAG_REMOTE_SDP_STR_REF(remote_sdp_str), - TAG_END()); - if(!sofia_session) { sofia_session = mrcp_sofia_session_create(sofia_agent,nh); if(!sofia_session) { @@ -340,6 +355,12 @@ static void mrcp_sofia_on_call_receive(mrcp_sofia_agent_t *sofia_agent, } } + descriptor = mrcp_session_descriptor_create(sofia_session->session->pool); + + tl_gets(tags, + SOATAG_REMOTE_SDP_STR_REF(remote_sdp_str), + TAG_END()); + if(remote_sdp_str) { sdp_parser_t *parser = NULL; sdp_session_t *sdp = NULL; @@ -349,12 +370,12 @@ static void mrcp_sofia_on_call_receive(mrcp_sofia_agent_t *sofia_agent, remote_sdp_str); parser = sdp_parse(sofia_session->home,remote_sdp_str,(int)strlen(remote_sdp_str),0); - sdp = sdp_session(parser); - descriptor = mrcp_descriptor_generate_by_sdp_session(sdp,NULL,sofia_session->session->pool); + sdp = sdp_session(parser); + status = mrcp_descriptor_generate_by_sdp_session(descriptor,sdp,NULL,sofia_session->session->pool); sdp_parser_free(parser); } - if(!descriptor) { + if(status == FALSE) { nua_respond(nh, SIP_400_BAD_REQUEST, TAG_END()); return; } @@ -379,16 +400,16 @@ static void mrcp_sofia_on_state_change(mrcp_sofia_agent_t *sofia_agent, sip_t const *sip, tagi_t tags[]) { - int ss_state = nua_callstate_init; + int nua_state = nua_callstate_init; tl_gets(tags, - NUTAG_CALLSTATE_REF(ss_state), + NUTAG_CALLSTATE_REF(nua_state), TAG_END()); apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"SIP Call State %s [%s]", sofia_session ? sofia_session->session->name : "", - nua_callstate_name(ss_state)); + nua_callstate_name(nua_state)); - switch(ss_state) { + switch(nua_state) { case nua_callstate_received: mrcp_sofia_on_call_receive(sofia_agent,nh,sofia_session,sip,tags); break; @@ -405,7 +426,7 @@ static void mrcp_sofia_on_resource_discover(mrcp_sofia_agent_t *sofia_agent, tagi_t tags[]) { char sdp_str[2048]; - char *local_sdp_str = NULL; + const char *local_sdp_str = NULL; const char *ip = sofia_agent->config->ext_ip ? sofia_agent->config->ext_ip : sofia_agent->config->local_ip; @@ -418,7 +439,7 @@ static void mrcp_sofia_on_resource_discover(mrcp_sofia_agent_t *sofia_agent, nua_respond(nh, SIP_200_OK, NUTAG_WITH_CURRENT(sofia_agent->nua), - SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str), + TAG_IF(sofia_agent->sip_contact_str,SIPTAG_CONTACT_STR(sofia_agent->sip_contact_str)), TAG_IF(local_sdp_str,SOATAG_USER_SDP_STR(local_sdp_str)), SOATAG_AUDIO_AUX("telephone-event"), TAG_END()); @@ -435,7 +456,11 @@ static void mrcp_sofia_event_callback( nua_event_t nua_event, sip_t const *sip, tagi_t tags[]) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive SIP Event [%s] Status %d %s",nua_event_name(nua_event),status,phrase); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive SIP Event [%s] Status %d %s [%s]", + nua_event_name(nua_event), + status, + phrase, + sofia_agent->sig_agent->id); switch(nua_event) { case nua_i_state: diff --git a/libs/unimrcp/modules/mrcp-unirtsp/Makefile.am b/libs/unimrcp/modules/mrcp-unirtsp/Makefile.am index 029233e4a4..479d631da3 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/Makefile.am +++ b/libs/unimrcp/modules/mrcp-unirtsp/Makefile.am @@ -1,7 +1,6 @@ -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in -AM_CPPFLAGS = -Iinclude \ - -I$(unimrcp_srcdir)/modules/mrcp-unirtsp/include \ +AM_CPPFLAGS = -I$(top_srcdir)/modules/mrcp-unirtsp/include \ -I$(top_srcdir)/libs/mrcp-signaling/include \ -I$(top_srcdir)/libs/mrcp/include \ -I$(top_srcdir)/libs/mrcp/message/include \ @@ -10,7 +9,7 @@ AM_CPPFLAGS = -Iinclude \ -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/uni-rtsp/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) $(UNIMRCP_SOFIA_INCLUDES) + $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_SOFIA_INCLUDES) noinst_LTLIBRARIES = libmrcpunirtsp.la diff --git a/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_client_agent.h b/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_client_agent.h index e455e4476e..bfc1a3f04e 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_client_agent.h +++ b/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_client_agent.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: mrcp_unirtsp_client_agent.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_unirtsp_client_agent.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_UNIRTSP_CLIENT_AGENT_H diff --git a/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_sdp.h b/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_sdp.h index 74de717a48..556b4b46d7 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_sdp.h +++ b/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_sdp.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: mrcp_unirtsp_sdp.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: mrcp_unirtsp_sdp.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_UNIRTSP_SDP_H diff --git a/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_server_agent.h b/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_server_agent.h index e93f692c5b..e83e8a5350 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_server_agent.h +++ b/libs/unimrcp/modules/mrcp-unirtsp/include/mrcp_unirtsp_server_agent.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: mrcp_unirtsp_server_agent.h 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_unirtsp_server_agent.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef MRCP_UNIRTSP_SERVER_AGENT_H diff --git a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2008.vcproj b/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2008.vcproj deleted file mode 100644 index d0d90c646d..0000000000 --- a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2008.vcproj +++ /dev/null @@ -1,293 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2010.vcxproj b/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.vcxproj similarity index 63% rename from libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2010.vcxproj rename to libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.vcxproj index f8a573d857..200d68b92b 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2010.vcxproj +++ b/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.vcxproj @@ -1,133 +1,146 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpunirtsp - {DEB01ACB-D65F-4A62-AED9-58C1054499E9} - mrcpunirtsp - Win32Proj - - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - StaticLibrary - Unicode - true - - - StaticLibrary - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - ProgramDatabase - - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DEB01ACB-D65F-4A62-AED9-58C1054499E9} + mrcpunirtsp + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + + + include;%(AdditionalIncludeDirectories) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + {12a49562-bab9-43a3-a21d-15b60bbb4c31} + false + + + {504b3154-7a4f-459d-9877-b951021c3f1f} + false + + + + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2010.vcxproj.filters b/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.vcxproj.filters similarity index 91% rename from libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2010.vcxproj.filters rename to libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.vcxproj.filters index a990550f29..3aff69f385 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2010.vcxproj.filters +++ b/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.vcxproj.filters @@ -1,35 +1,35 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {f87f8ada-12d1-412b-bd14-7e62df3f92a0} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - - - src - - - src - - - src - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {1ae8fa5f-5d29-4bd7-a332-b2e917a801ca} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + + + src + + + src + + + src + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_client_agent.c b/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_client_agent.c index 6997c47004..321e3e48f7 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_client_agent.c +++ b/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_client_agent.c @@ -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: mrcp_unirtsp_client_agent.c 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_unirtsp_client_agent.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -85,7 +85,7 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_unirtsp_client_agent_create(const char *id, apt_task_t *task; mrcp_unirtsp_agent_t *agent; agent = apr_palloc(pool,sizeof(mrcp_unirtsp_agent_t)); - agent->sig_agent = mrcp_signaling_agent_create(id,agent,MRCP_VERSION_1,pool); + agent->sig_agent = mrcp_signaling_agent_create(id,agent,pool); agent->sig_agent->create_client_session = mrcp_unirtsp_session_create; agent->config = config; @@ -94,6 +94,7 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_unirtsp_client_agent_create(const char *id, } agent->rtsp_client = rtsp_client_create( + id, config->max_connection_count, config->request_timeout, agent, @@ -104,11 +105,8 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_unirtsp_client_agent_create(const char *id, } task = rtsp_client_task_get(agent->rtsp_client); - apt_task_name_set(task,id); agent->sig_agent->task = task; - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create UniRTSP Agent [%s] [%"APR_SIZE_T_FMT"]", - id,config->max_connection_count); return agent->sig_agent; } @@ -317,10 +315,16 @@ static apt_bool_t mrcp_unirtsp_on_session_event(rtsp_client_t *rtsp_client, rtsp { mrcp_unirtsp_agent_t *agent = rtsp_client_object_get(rtsp_client); mrcp_unirtsp_session_t *session = rtsp_client_session_object_get(rtsp_session); - const char *resource_name = mrcp_name_get_by_rtsp_name( + const char *resource_name; + + if(!session) { + return FALSE; + } + + resource_name = mrcp_name_get_by_rtsp_name( session->rtsp_settings->resource_map, message->start_line.common.request_line.resource_name); - if(!session || !resource_name) { + if(!resource_name) { return FALSE; } @@ -355,7 +359,7 @@ static apt_bool_t mrcp_unirtsp_session_control(mrcp_session_t *mrcp_session, mrc mrcp_unirtsp_session_t *session = mrcp_session->obj; mrcp_unirtsp_agent_t *agent = mrcp_session->signaling_agent->obj; - char buffer[500]; + char buffer[2000]; apt_text_stream_t stream; rtsp_message_t *rtsp_message = NULL; apt_str_t *body; diff --git a/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c b/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c index ebb31fa007..fa546179b3 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c +++ b/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c @@ -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: mrcp_unirtsp_sdp.c 1752 2010-08-09 19:05:23Z achaloyan $ + * $Id: mrcp_unirtsp_sdp.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -22,32 +22,37 @@ #include "rtsp_message.h" #include "mrcp_unirtsp_sdp.h" #include "mpf_rtp_attribs.h" +#include "mpf_rtp_pt.h" #include "apt_text_stream.h" #include "apt_log.h" - /** Generate SDP media by RTP media descriptor */ static apr_size_t sdp_rtp_media_generate(char *buffer, apr_size_t size, const mrcp_session_descriptor_t *descriptor, const mpf_rtp_media_descriptor_t *audio_media) { apr_size_t offset = 0; - int i; - mpf_codec_descriptor_t *codec_descriptor; - apr_array_header_t *descriptor_arr = audio_media->codec_list.descriptor_arr; - if(!descriptor_arr) { - return 0; - } - offset += snprintf(buffer+offset,size-offset, - "m=audio %d RTP/AVP", - audio_media->state == MPF_MEDIA_ENABLED ? audio_media->port : 0); - for(i=0; inelts; i++) { - codec_descriptor = &APR_ARRAY_IDX(descriptor_arr,i,mpf_codec_descriptor_t); - if(codec_descriptor->enabled == TRUE) { - offset += snprintf(buffer+offset,size-offset," %d", codec_descriptor->payload_type); - } - } - offset += snprintf(buffer+offset,size-offset,"\r\n"); if(audio_media->state == MPF_MEDIA_ENABLED) { - const apt_str_t *direction_str = mpf_rtp_direction_str_get(audio_media->direction); + int codec_count = 0; + int i; + mpf_codec_descriptor_t *codec_descriptor; + apr_array_header_t *descriptor_arr = audio_media->codec_list.descriptor_arr; + const apt_str_t *direction_str; + if(!descriptor_arr) { + return 0; + } + offset += snprintf(buffer+offset,size-offset,"m=audio %d RTP/AVP",audio_media->port); + for(i=0; inelts; i++) { + codec_descriptor = &APR_ARRAY_IDX(descriptor_arr,i,mpf_codec_descriptor_t); + if(codec_descriptor->enabled == TRUE) { + offset += snprintf(buffer+offset,size-offset," %d",codec_descriptor->payload_type); + codec_count++; + } + } + if(!codec_count){ + /* SDP m line should have at least one media format listed; use a reserved RTP payload type */ + offset += snprintf(buffer+offset,size-offset," %d",RTP_PT_RESERVED); + } + offset += snprintf(buffer+offset,size-offset,"\r\n"); + for(i=0; inelts; i++) { codec_descriptor = &APR_ARRAY_IDX(descriptor_arr,i,mpf_codec_descriptor_t); if(codec_descriptor->enabled == TRUE && codec_descriptor->name.buf) { @@ -62,15 +67,20 @@ static apr_size_t sdp_rtp_media_generate(char *buffer, apr_size_t size, const mr } } } + + direction_str = mpf_rtp_direction_str_get(audio_media->direction); if(direction_str) { offset += snprintf(buffer+offset,size-offset,"a=%s\r\n",direction_str->buf); } if(audio_media->ptime) { - offset += snprintf(buffer+offset,size-offset,"a=ptime:%hu\r\n", - audio_media->ptime); + offset += snprintf(buffer+offset,size-offset,"a=ptime:%hu\r\n",audio_media->ptime); } } + else { + offset += snprintf(buffer+offset,size-offset,"m=audio 0 RTP/AVP %d\r\n",RTP_PT_RESERVED); + } + return offset; } @@ -137,7 +147,7 @@ static apt_bool_t mpf_rtp_media_generate(mpf_rtp_media_descriptor_t *rtp_media, } /** Generate MRCP descriptor by SDP session */ -static mrcp_session_descriptor_t* mrcp_descriptor_generate_by_sdp_session(mrcp_session_descriptor_t *descriptor, const sdp_session_t *sdp, const char *force_destination_ip, apr_pool_t *pool) +static apt_bool_t mrcp_descriptor_generate_by_rtsp_sdp_session(mrcp_session_descriptor_t *descriptor, const sdp_session_t *sdp, const char *force_destination_ip, apr_pool_t *pool) { sdp_media_t *sdp_media; @@ -171,10 +181,9 @@ static mrcp_session_descriptor_t* mrcp_descriptor_generate_by_sdp_session(mrcp_s break; } } - return descriptor; + return TRUE; } - /** Generate MRCP descriptor by RTSP request */ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_rtsp_request( const rtsp_message_t *request, @@ -190,7 +199,7 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_rtsp_reques if(!resource_name) { return NULL; } - + if(request->start_line.common.request_line.method_id == RTSP_METHOD_SETUP) { if(rtsp_header_property_check(&request->header,RTSP_HEADER_FIELD_CONTENT_TYPE) == TRUE && rtsp_header_property_check(&request->header,RTSP_HEADER_FIELD_CONTENT_LENGTH) == TRUE && @@ -203,7 +212,7 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_rtsp_reques sdp = sdp_session(parser); if(sdp) { descriptor = mrcp_session_descriptor_create(pool); - mrcp_descriptor_generate_by_sdp_session(descriptor,sdp,force_destination_ip,pool); + mrcp_descriptor_generate_by_rtsp_sdp_session(descriptor,sdp,force_destination_ip,pool); } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Parse SDP Message"); @@ -253,12 +262,12 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_rtsp_respon if(!resource_name) { return NULL; } - + if(request->start_line.common.request_line.method_id == RTSP_METHOD_SETUP) { if(rtsp_header_property_check(&response->header,RTSP_HEADER_FIELD_CONTENT_TYPE) == TRUE && rtsp_header_property_check(&response->header,RTSP_HEADER_FIELD_CONTENT_LENGTH) == TRUE && response->body.buf) { - + sdp_parser_t *parser; sdp_session_t *sdp; @@ -266,15 +275,16 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_descriptor_generate_by_rtsp_respon sdp = sdp_session(parser); if(sdp) { descriptor = mrcp_session_descriptor_create(pool); - mrcp_descriptor_generate_by_sdp_session(descriptor,sdp,force_destination_ip,pool); + mrcp_descriptor_generate_by_rtsp_sdp_session(descriptor,sdp,force_destination_ip,pool); apt_string_assign(&descriptor->resource_name,resource_name,pool); descriptor->resource_state = TRUE; + descriptor->response_code = response->start_line.common.status_line.status_code; } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Parse SDP Message"); } - + sdp_parser_free(parser); } else { @@ -486,15 +496,16 @@ MRCP_DECLARE(mrcp_session_descriptor_t*) mrcp_resource_discovery_response_genera if(rtsp_header_property_check(&response->header,RTSP_HEADER_FIELD_CONTENT_TYPE) == TRUE && rtsp_header_property_check(&response->header,RTSP_HEADER_FIELD_CONTENT_LENGTH) == TRUE && response->body.buf) { - + sdp_parser_t *parser; sdp_session_t *sdp; parser = sdp_parse(home,response->body.buf,response->body.length,0); sdp = sdp_session(parser); if(sdp) { - mrcp_descriptor_generate_by_sdp_session(descriptor,sdp,0,pool); + mrcp_descriptor_generate_by_rtsp_sdp_session(descriptor,sdp,0,pool); descriptor->resource_state = TRUE; + descriptor->response_code = response->start_line.common.status_line.status_code; } else { apt_string_assign(&descriptor->resource_name,resource_name,pool); diff --git a/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_server_agent.c b/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_server_agent.c index 873b3d216d..a05614763f 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_server_agent.c +++ b/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_server_agent.c @@ -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: mrcp_unirtsp_server_agent.c 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mrcp_unirtsp_server_agent.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -54,7 +54,8 @@ static apt_bool_t mrcp_unirtsp_on_session_control(mrcp_session_t *session, mrcp_ static const mrcp_session_response_vtable_t session_response_vtable = { mrcp_unirtsp_on_session_answer, mrcp_unirtsp_on_session_terminate, - mrcp_unirtsp_on_session_control + mrcp_unirtsp_on_session_control, + NULL /* mrcp_unirtsp_on_session_discover */ }; static apt_bool_t mrcp_unirtsp_session_create(rtsp_server_t *server, rtsp_server_session_t *session); @@ -77,7 +78,7 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_unirtsp_server_agent_create(const char *id, apt_task_t *task; mrcp_unirtsp_agent_t *agent; agent = apr_palloc(pool,sizeof(mrcp_unirtsp_agent_t)); - agent->sig_agent = mrcp_signaling_agent_create(id,agent,MRCP_VERSION_1,pool); + agent->sig_agent = mrcp_signaling_agent_create(id,agent,pool); agent->config = config; if(rtsp_config_validate(agent,config,pool) == FALSE) { @@ -85,25 +86,20 @@ MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_unirtsp_server_agent_create(const char *id, } agent->rtsp_server = rtsp_server_create( - config->local_ip, - config->local_port, - config->max_connection_count, - agent, - &session_request_vtable, - pool); + id, + config->local_ip, + config->local_port, + config->max_connection_count, + agent, + &session_request_vtable, + pool); if(!agent->rtsp_server) { return NULL; } - + task = rtsp_server_task_get(agent->rtsp_server); - apt_task_name_set(task,id); agent->sig_agent->task = task; - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create UniRTSP Agent [%s] %s:%hu [%"APR_SIZE_T_FMT"]", - id, - config->local_ip, - config->local_port, - config->max_connection_count); return agent->sig_agent; } @@ -332,7 +328,7 @@ static apt_bool_t mrcp_unirtsp_on_session_control(mrcp_session_t *mrcp_session, mrcp_unirtsp_session_t *session = mrcp_session->obj; mrcp_unirtsp_agent_t *agent = mrcp_session->signaling_agent->obj; - char buffer[500]; + char buffer[2000]; apt_text_stream_t stream; rtsp_message_t *rtsp_message = NULL; apt_str_t *body; diff --git a/libs/unimrcp/packages/inno-setup/setup.txt b/libs/unimrcp/packages/inno-setup/setup.txt index 45d6489f83..4091232256 100644 --- a/libs/unimrcp/packages/inno-setup/setup.txt +++ b/libs/unimrcp/packages/inno-setup/setup.txt @@ -1,8 +1,8 @@ -#define uni_version "1.0.0" +#define uni_version "1.2.0" #define uni_src "..\.." AppName=UniMRCP -AppVerName=UniMRCP-{#= uni_version} +AppVerName=UniMRCP {#= uni_version} AppPublisher=UniMRCP AppPublisherURL=http://www.unimrcp.org/ AppSupportURL=http://groups.google.com/group/unimrcp diff --git a/libs/unimrcp/packages/inno-setup/unimrcp-sdk.iss b/libs/unimrcp/packages/inno-setup/unimrcp-sdk.iss index 6391602921..8fb56cea1b 100644 --- a/libs/unimrcp/packages/inno-setup/unimrcp-sdk.iss +++ b/libs/unimrcp/packages/inno-setup/unimrcp-sdk.iss @@ -13,7 +13,7 @@ Name: custom; Description: Custom installation; Flags: iscustom Name: sdk; Description: UniMRCP SDK (client, server and plugin development); Types: full sdk Name: docs; Description: UniMRCP documentation; Types: full docs Name: docs\design; Description: Design concepts; Types: full docs -Name: docs\api; Description: API; Types: full docs +Name: docs\api; Description: API reference; Types: full docs [Files] Source: {#= uni_src}\libs\apr\include\*.h; DestDir: {app}\include; Components: sdk @@ -34,7 +34,9 @@ Source: {#= uni_src}\{#= release_dir}\lib\*.lib; DestDir: {app}\lib; Components: Source: {#= uni_src}\libs\apr\{#= release_dir}\*.lib; DestDir: {app}\lib; Components: sdk Source: {#= uni_src}\libs\apr-util\{#= release_dir}\*.lib; DestDir: {app}\lib; Components: sdk Source: {#= uni_src}\libs\sofia-sip\win32\libsofia-sip-ua\{#= release_dir}\*.lib; DestDir: {app}\lib; Components: sdk -Source: {#= uni_src}\build\vsprops\sdk\*.vsprops; DestDir: {app}\vsprops; Components: sdk; AfterInstall: SetProjectPath() +Source: {#= uni_src}\build\*.h; DestDir: {app}\include; Components: sdk +Source: {#= uni_src}\build\props\sdk\*.props; DestDir: {app}\props; Components: sdk; AfterInstall: SetProjectPath(ExpandConstant('{app}\props\unimrcpsdk.props')) +Source: {#= uni_src}\build\vsprops\sdk\*.vsprops; DestDir: {app}\vsprops; Components: sdk; AfterInstall: SetProjectPath(ExpandConstant('{app}\vsprops\unimrcpsdk.vsprops')) Source: {#= uni_src}\docs\ea\*; DestDir: {app}\doc\ea; Components: docs/design; Flags: recursesubdirs Source: {#= uni_src}\docs\dox\*; DestDir: {app}\doc\dox; Components: docs/api; Flags: recursesubdirs @@ -44,14 +46,11 @@ Name: {group}\UniMRCP Docs\API; Filename: {app}\doc\dox\html\index.html; Compone Name: {group}\Uninstall; Filename: {uninstallexe} [Code] -procedure SetProjectPath(); +procedure SetProjectPath(PropertySheetFile: String); var - VspropsFile: String; Content: String; begin - VspropsFile := ExpandConstant('{app}\vsprops\unimrcpsdk.vsprops'); - LoadStringFromFile (VspropsFile, Content); - StringChange (Content, 'Value="C:\Program Files\UniMRCP"', ExpandConstant('Value="{app}"')); - SaveStringToFile (VspropsFile, Content, False); + LoadStringFromFile (PropertySheetFile, Content); + StringChange (Content, 'C:\Program Files\UniMRCP', ExpandConstant('{app}')); + SaveStringToFile (PropertySheetFile, Content, False); end; - diff --git a/libs/unimrcp/packages/inno-setup/unimrcp.iss b/libs/unimrcp/packages/inno-setup/unimrcp.iss index 9e65059430..b4e9852a45 100644 --- a/libs/unimrcp/packages/inno-setup/unimrcp.iss +++ b/libs/unimrcp/packages/inno-setup/unimrcp.iss @@ -14,7 +14,8 @@ Name: server; Description: UniMRCP server; Types: full server Name: server\recorder; Description: Recorder plugin; Types: full server Name: server\demosynth; Description: Demo synthesizer plugin; Types: full server Name: server\demorecog; Description: Demo recognizer plugin; Types: full server -Name: client; Description: UniMRCP client (demo application); Types: full client +Name: server\demoverifier; Description: Demo verifier plugin; Types: full server +Name: client; Description: UniMRCP client (sample applications); Types: full client [Dirs] Name: {app}\data; Permissions: everyone-full @@ -29,12 +30,14 @@ Source: {#= uni_outdir}\bin\*.dll; DestDir: {app}\bin; Components: server client Source: {#= uni_outdir}\plugin\mrcprecorder.dll; DestDir: {app}\plugin; Components: server/recorder Source: {#= uni_outdir}\plugin\demosynth.dll; DestDir: {app}\plugin; Components: server/demosynth Source: {#= uni_outdir}\plugin\demorecog.dll; DestDir: {app}\plugin; Components: server/demorecog +Source: {#= uni_outdir}\plugin\demoverifier.dll; DestDir: {app}\plugin; Components: server/demoverifier Source: {#= uni_outdir}\conf\unimrcpserver.xml; DestDir: {app}\conf; Components: server Source: {#= uni_outdir}\conf\unimrcpclient.xml; DestDir: {app}\conf; Components: client Source: {#= uni_outdir}\conf\client-profiles\*.xml; DestDir: {app}\conf\client-profiles; Components: client Source: {#= uni_outdir}\conf\umcscenarios.xml; DestDir: {app}\conf; Components: client Source: {#= uni_outdir}\data\*.pcm; DestDir: {app}\data; Components: server client Source: {#= uni_outdir}\data\*.xml; DestDir: {app}\data; Components: server client +Source: {#= uni_outdir}\data\*.txt; DestDir: {app}\data; Components: server client [Icons] Name: {group}\UniMRCP Server Console; Filename: {app}\bin\unimrcpserver.exe; Parameters: "--root-dir ""{app}"""; Components: server @@ -82,7 +85,7 @@ begin ModifyPluginConf ('mrcprecorder', IsComponentSelected('server\recorder')); ModifyPluginConf ('demosynth', IsComponentSelected('server\demosynth')); ModifyPluginConf ('demorecog', IsComponentSelected('server\demorecog')); + ModifyPluginConf ('demoverifier', IsComponentSelected('server\demoverifier')); SaveStringToFile (CfgFile, Content, False); end end; - diff --git a/libs/unimrcp/platforms/Makefile.am b/libs/unimrcp/platforms/Makefile.am index 7d0fb6dfd5..13fc51f34e 100644 --- a/libs/unimrcp/platforms/Makefile.am +++ b/libs/unimrcp/platforms/Makefile.am @@ -1,6 +1,27 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = libunimrcp-server unimrcp-server \ - libunimrcp-client unimrcp-client \ - libasr-client asr-client \ - umc +SUBDIRS = + +if UNIMRCP_CLIENT_LIB +SUBDIRS += libunimrcp-client +endif + +if UNIMRCP_CLIENT_APP +SUBDIRS += unimrcp-client +endif + +if UMC +SUBDIRS += umc +endif + +if ASR_CLIENT +SUBDIRS += libasr-client asr-client +endif + +if UNIMRCP_SERVER_LIB +SUBDIRS += libunimrcp-server +endif + +if UNIMRCP_SERVER_APP +SUBDIRS += unimrcp-server +endif diff --git a/libs/unimrcp/platforms/asr-client/Makefile.am b/libs/unimrcp/platforms/asr-client/Makefile.am index b0f057a2b4..62371acd75 100644 --- a/libs/unimrcp/platforms/asr-client/Makefile.am +++ b/libs/unimrcp/platforms/asr-client/Makefile.am @@ -1,24 +1,10 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/platforms/libasr-client/include \ - -I$(top_srcdir)/platforms/libunimrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = -I$(top_srcdir)/platforms/libasr-client/include \ + $(UNIMRCP_CLIENTAPP_INCLUDES) bin_PROGRAMS = asrclient -asrclient_SOURCES = src/main.c - -asrclient_LDADD = $(top_builddir)/platforms/libasr-client/libasrclient.la -if ISMAC -asrclient_LDFLAGS = -framework CoreFoundation -framework SystemConfiguration -endif +asrclient_SOURCES = src/main.c +asrclient_LDADD = $(top_builddir)/platforms/libasr-client/libasrclient.la +asrclient_LDFLAGS = $(UNIMRCP_CLIENTAPP_OPTS) + +include $(top_srcdir)/build/rules/uniclientapp.am diff --git a/libs/unimrcp/platforms/asr-client/asrclient.vcxproj b/libs/unimrcp/platforms/asr-client/asrclient.vcxproj new file mode 100644 index 0000000000..5e20263b20 --- /dev/null +++ b/libs/unimrcp/platforms/asr-client/asrclient.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684} + asrclient + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;..\libasr-client\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + libasrclient.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + include;..\libasr-client\include;%(AdditionalIncludeDirectories) + + + libasrclient.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + include;..\libasr-client\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + ProgramDatabase + + + libasrclient.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + X64 + + + include;..\libasr-client\include;%(AdditionalIncludeDirectories) + + + libasrclient.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + {272fafa8-2b2f-4716-b95f-3b37cf2e0cb3} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/asr-client/asrclient.vcxproj.filters b/libs/unimrcp/platforms/asr-client/asrclient.vcxproj.filters new file mode 100644 index 0000000000..3efc5f63ae --- /dev/null +++ b/libs/unimrcp/platforms/asr-client/asrclient.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/asr-client/src/main.c b/libs/unimrcp/platforms/asr-client/src/main.c index 8a3a1d06de..10f97cd065 100644 --- a/libs/unimrcp/platforms/asr-client/src/main.c +++ b/libs/unimrcp/platforms/asr-client/src/main.c @@ -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.c 1541 2010-02-22 20:20:10Z achaloyan $ + * $Id: main.c 2213 2014-11-06 03:02:45Z achaloyan@gmail.com $ */ #include @@ -146,7 +146,7 @@ static apt_bool_t cmdline_run(asr_engine_t *engine) { apt_bool_t running = TRUE; char cmdline[1024]; - int i; + apr_size_t i; do { printf(">"); memset(&cmdline, 0, sizeof(cmdline)); @@ -165,7 +165,7 @@ static apt_bool_t cmdline_run(asr_engine_t *engine) return TRUE; } -static void usage() +static void usage(void) { printf( "\n" @@ -220,7 +220,7 @@ static client_options_t* options_load(int argc, const char * const *argv) options = apr_palloc(pool,sizeof(client_options_t)); options->pool = pool; /* set the default options */ - options->root_dir_path = "../"; + options->root_dir_path = NULL; options->log_priority = APT_PRIO_INFO; options->log_output = APT_LOG_OUTPUT_CONSOLE; diff --git a/libs/unimrcp/platforms/libasr-client/Makefile.am b/libs/unimrcp/platforms/libasr-client/Makefile.am index 58bde0f625..68ecd07b6a 100644 --- a/libs/unimrcp/platforms/libasr-client/Makefile.am +++ b/libs/unimrcp/platforms/libasr-client/Makefile.am @@ -1,25 +1,12 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(unimrcp_srcdir)/platforms/libasr-client/include \ +AM_CPPFLAGS = -I$(top_srcdir)/platforms/libasr-client/include \ -I$(top_srcdir)/platforms/libunimrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_CLIENTLIB_INCLUDES) lib_LTLIBRARIES = libasrclient.la include_HEADERS = include/asr_engine.h - libasrclient_la_SOURCES = src/asr_engine.c - libasrclient_la_LIBADD = $(top_builddir)/platforms/libunimrcp-client/libunimrcpclient.la - -libasrclient_la_LDFLAGS = $(UNI_LT_VERSION) +libasrclient_la_LDFLAGS = $(UNIMRCP_CLIENTLIB_OPTS) + +include $(top_srcdir)/build/rules/uniclientlib.am diff --git a/libs/unimrcp/platforms/libasr-client/include/asr_engine.h b/libs/unimrcp/platforms/libasr-client/include/asr_engine.h index 065e7f83f9..fbb2261eab 100644 --- a/libs/unimrcp/platforms/libasr-client/include/asr_engine.h +++ b/libs/unimrcp/platforms/libasr-client/include/asr_engine.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Arsen Chaloyan + * Copyright 2009-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: asr_engine.h 1566 2010-03-06 16:45:05Z achaloyan $ + * $Id: asr_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef ASR_ENGINE_H diff --git a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj b/libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj similarity index 54% rename from libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj rename to libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj index e437916ee8..0323b37fcf 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj +++ b/libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj @@ -1,137 +1,148 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpunirtsp - {DEB01ACB-D65F-4A62-AED9-58C1054499E9} - mrcpunirtsp - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - ProgramDatabase - - - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - X64 - - - include;%(AdditionalIncludeDirectories) - APT_STATIC_LIB;RTSP_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;LIBSOFIA_SIP_UA_STATIC;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3} + libasrclient + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + ASR_CLIENT_LIB_EXPORT;%(PreprocessorDefinitions) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + true + + + + + include;%(AdditionalIncludeDirectories) + ASR_CLIENT_LIB_EXPORT;%(PreprocessorDefinitions) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + true + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ASR_CLIENT_LIB_EXPORT;%(PreprocessorDefinitions) + ProgramDatabase + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ASR_CLIENT_LIB_EXPORT;%(PreprocessorDefinitions) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + + + + + + + + + + + {ee157390-1e85-416c-946e-620e32c9ad33} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj.filters b/libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj.filters new file mode 100644 index 0000000000..3bdaf623d4 --- /dev/null +++ b/libs/unimrcp/platforms/libasr-client/libasrclient.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {21e6c16e-f977-468a-9576-0c5981eb7da5} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/libasr-client/src/asr_engine.c b/libs/unimrcp/platforms/libasr-client/src/asr_engine.c index 4048347a05..1473a89604 100644 --- a/libs/unimrcp/platforms/libasr-client/src/asr_engine.c +++ b/libs/unimrcp/platforms/libasr-client/src/asr_engine.c @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010 Arsen Chaloyan + * Copyright 2009-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: asr_engine.c 1785 2010-09-22 06:14:29Z achaloyan $ + * $Id: asr_engine.c 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $ */ #include @@ -96,6 +96,7 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = { asr_stream_read, NULL, NULL, + NULL, NULL }; @@ -127,7 +128,8 @@ ASR_CLIENT_DECLARE(asr_engine_t*) asr_engine_create( if((log_output & APT_LOG_OUTPUT_FILE) == APT_LOG_OUTPUT_FILE) { /* 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); } engine = apr_palloc(pool,sizeof(asr_engine_t)); @@ -291,17 +293,32 @@ static mrcp_message_t* define_grammar_message_create(asr_session_t *asr_session, apr_pool_t *pool = mrcp_application_session_pool_get(asr_session->mrcp_session); char *grammar_file_path = apt_datadir_filepath_get(dir_layout,grammar_file,pool); if(grammar_file_path) { - char text[1024]; - apr_size_t size; - FILE *grammar = fopen(grammar_file_path,"r"); - if(!grammar) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Open [%s]",grammar_file_path); + apr_finfo_t finfo; + apr_file_t *grammar_file; + apt_str_t *content = &mrcp_message->body; + + if(apr_file_open(&grammar_file,grammar_file_path,APR_FOPEN_READ|APR_FOPEN_BINARY,0,pool) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Grammar File %s",grammar_file_path); return NULL; } - size = fread(text,1,sizeof(text),grammar); - apt_string_assign_n(&mrcp_message->body,text,size,mrcp_message->pool); - fclose(grammar); + if(apr_file_info_get(&finfo,APR_FINFO_SIZE,grammar_file) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Grammar File Info %s",grammar_file_path); + apr_file_close(grammar_file); + return NULL; + } + + content->length = (apr_size_t)finfo.size; + content->buf = (char*) apr_palloc(pool,content->length+1); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Load Grammar File Content size [%"APR_SIZE_T_FMT" bytes] %s", + content->length,grammar_file_path); + if(apr_file_read(grammar_file,content->buf,&content->length) != APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Read Grammar File Content %s",grammar_file_path); + apr_file_close(grammar_file); + return NULL; + } + content->buf[content->length] = '\0'; + apr_file_close(grammar_file); } /* get/allocate generic header */ @@ -369,30 +386,30 @@ static mrcp_message_t* recognize_message_create(asr_session_t *asr_session) return mrcp_message; } -/** Get NLSML input result */ -static const char* nlsml_input_get(mrcp_message_t *message) +/** Get NLSML result */ +static const char* nlsml_result_get(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) { + nlsml_interpretation_t *interpretation; + nlsml_instance_t *instance; + nlsml_result_t *result = nlsml_result_parse(message->body.buf, message->body.length, message->pool); + if(!result) { return NULL; } - /* get interpreted result */ - interpret = nlsml_first_interpret_get(doc); - if(!interpret) { - return NULL; - } - /* get instance and input */ - nlsml_interpret_results_get(interpret,&instance,&input); - if(!input || !input->first_cdata.first) { + /* get first interpretation */ + interpretation = nlsml_first_interpretation_get(result); + if(!interpretation) { return NULL; } - /* return input */ - return input->first_cdata.first->text; + /* get first instance */ + instance = nlsml_interpretation_first_instance_get(interpretation); + if(!instance) { + return NULL; + } + + nlsml_instance_swi_suppress(instance); + return nlsml_instance_content_generate(instance, message->pool); } @@ -619,7 +636,7 @@ ASR_CLIENT_DECLARE(const char*) asr_session_file_recognize( while(!asr_session->recog_complete); /* Get results */ - return nlsml_input_get(asr_session->recog_complete); + return nlsml_result_get(asr_session->recog_complete); } /** Initiate recognition based on specified grammar and input stream */ @@ -700,7 +717,7 @@ ASR_CLIENT_DECLARE(const char*) asr_session_stream_recognize( while(!asr_session->recog_complete); /* Get results */ - return nlsml_input_get(asr_session->recog_complete); + return nlsml_result_get(asr_session->recog_complete); } /** Write audio frame to recognize */ diff --git a/libs/unimrcp/platforms/libunimrcp-client/Makefile.am b/libs/unimrcp/platforms/libunimrcp-client/Makefile.am index d6e73e4919..28bc44aac3 100644 --- a/libs/unimrcp/platforms/libunimrcp-client/Makefile.am +++ b/libs/unimrcp/platforms/libunimrcp-client/Makefile.am @@ -1,34 +1,11 @@ -MAINTAINERCLEANFILES = Makefile.in - AM_CPPFLAGS = -I$(top_srcdir)/platforms/libunimrcp-client/include \ - -I$(unimrcp_srcdir)/modules/mrcp-sofiasip/include \ - -I$(top_srcdir)/modules/mrcp-unirtsp/include \ - -I$(top_srcdir)/libs/mrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - -I$(top_srcdir)/build \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_CLIENTLIB_INCLUDES) lib_LTLIBRARIES = libunimrcpclient.la include_HEADERS = include/unimrcp_client.h - libunimrcpclient_la_SOURCES = src/unimrcp_client.c +libunimrcpclient_la_LIBADD = $(UNIMRCP_CLIENTLIB_LIBS) +libunimrcpclient_la_LDFLAGS = $(UNIMRCP_CLIENTLIB_OPTS) -libunimrcpclient_la_LIBADD = $(top_builddir)/modules/mrcp-sofiasip/libmrcpsofiasip.la \ - $(top_builddir)/modules/mrcp-unirtsp/libmrcpunirtsp.la \ - $(top_builddir)/libs/mrcpv2-transport/libmrcpv2transport.la \ - $(top_builddir)/libs/mrcp-client/libmrcpclient.la \ - $(top_builddir)/libs/mrcp-signaling/libmrcpsignaling.la \ - $(top_builddir)/libs/mrcp/libmrcp.la \ - $(top_builddir)/libs/mpf/libmpf.la \ - $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) $(UNIMRCP_SOFIA_LIBS) -lm - -libunimrcpclient_la_LDFLAGS = $(UNI_LT_VERSION) +include $(top_srcdir)/build/rules/uniclientlib.am diff --git a/libs/unimrcp/platforms/libunimrcp-client/include/unimrcp_client.h b/libs/unimrcp/platforms/libunimrcp-client/include/unimrcp_client.h index 2efff488c4..b1536f4c0c 100644 --- a/libs/unimrcp/platforms/libunimrcp-client/include/unimrcp_client.h +++ b/libs/unimrcp/platforms/libunimrcp-client/include/unimrcp_client.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: unimrcp_client.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: unimrcp_client.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef UNIMRCP_CLIENT_H @@ -34,6 +34,12 @@ APT_BEGIN_EXTERN_C */ MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create(apt_dir_layout_t *dir_layout); +/** + * Create UniMRCP client. + * @param xmlconfig XML configuration string + */ +MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create2(const char *xmlconfig); + APT_END_EXTERN_C diff --git a/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.2008.vcproj b/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.2008.vcproj deleted file mode 100644 index da06fd96d9..0000000000 --- a/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.2008.vcproj +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj b/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj new file mode 100644 index 0000000000..2c2d99ea50 --- /dev/null +++ b/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {EE157390-1E85-416C-946E-620E32C9AD33} + libunimrcpclient + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + + + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + + + + + X64 + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + {72782932-37cc-46ae-8c7f-9a7b1a6ee108} + false + + + {746f3632-5bb2-4570-9453-31d6d58a7d8e} + false + + + {deb01acb-d65f-4a62-aed9-58c1054499e9} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj.filters b/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj.filters new file mode 100644 index 0000000000..a2d863b27f --- /dev/null +++ b/libs/unimrcp/platforms/libunimrcp-client/libunimrcpclient.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {15d2ec58-ba87-4dd8-9f7a-434f9e186e4e} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c b/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c index 3ef85f3329..5218fb1021 100644 --- a/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c +++ b/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c @@ -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: unimrcp_client.c 1750 2010-07-23 19:33:34Z achaloyan $ + * $Id: unimrcp_client.c 2231 2014-11-12 01:32:03Z achaloyan@gmail.com $ */ #include @@ -21,19 +21,21 @@ #include #include #include "uni_version.h" +#include "uni_revision.h" #include "unimrcp_client.h" #include "mrcp_resource_loader.h" #include "mpf_engine.h" +#include "mpf_engine_factory.h" #include "mpf_codec_manager.h" #include "mpf_rtp_termination_factory.h" #include "mrcp_sofiasip_client_agent.h" #include "mrcp_unirtsp_client_agent.h" #include "mrcp_client_connection.h" +#include "mrcp_ca_factory.h" #include "apt_net.h" #include "apt_log.h" #define CONF_FILE_NAME "unimrcpclient.xml" -#define DEFAULT_CONF_DIR_PATH "../conf" #define DEFAULT_IP_ADDRESS "127.0.0.1" #define DEFAULT_SIP_PORT 8062 @@ -53,6 +55,8 @@ typedef struct unimrcp_client_loader_t unimrcp_client_loader_t; struct unimrcp_client_loader_t { /** MRCP client */ mrcp_client_t *client; + /** Directory layout */ + apt_dir_layout_t *dir_layout; /** XML document */ apr_xml_doc *doc; /** Pool to allocate memory from */ @@ -69,21 +73,17 @@ struct unimrcp_client_loader_t { const char *auto_ip; }; -static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const char *dir_path, const char *file_name, apr_pool_t *pool); +static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const char *dir_path, const char *file_name); +static apt_bool_t unimrcp_client_load2(unimrcp_client_loader_t *loader, const char *xmlconfig); -/** Create and load UniMRCP client */ -MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create(apt_dir_layout_t *dir_layout) +/** Initialize client -- common to unimrcp_client_create and unimrcp_client_create2 */ +static unimrcp_client_loader_t* unimrcp_client_init(apt_dir_layout_t *dir_layout) { apr_pool_t *pool; mrcp_client_t *client; - const char *dir_path; unimrcp_client_loader_t *loader; - if(!dir_layout) { - return NULL; - } - - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"UniMRCP Client ["UNI_VERSION_STRING"]"); + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"UniMRCP Client ["UNI_VERSION_STRING"] [r"UNI_REVISION_STRING"]"); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"APR ["APR_VERSION_STRING"]"); client = mrcp_client_create(dir_layout); if(!client) { @@ -95,6 +95,7 @@ MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create(apt_dir_layout_t *dir_layout) } loader = apr_palloc(pool,sizeof(unimrcp_client_loader_t)); + loader->dir_layout = dir_layout; loader->doc = NULL; loader->client = client; loader->pool = pool; @@ -102,23 +103,52 @@ MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create(apt_dir_layout_t *dir_layout) loader->ext_ip = NULL; loader->server_ip = NULL; loader->auto_ip = NULL; + return loader; +} - dir_path = dir_layout->conf_dir_path; - if(!dir_path) { - dir_path = DEFAULT_CONF_DIR_PATH; +/** Create and load UniMRCP client using the directories layout */ +MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create(apt_dir_layout_t *dir_layout) +{ + const char *dir_path; + unimrcp_client_loader_t *loader; + + if(!dir_layout) { + return NULL; } - if(unimrcp_client_load(loader,dir_path,CONF_FILE_NAME,pool) == FALSE) { + loader = unimrcp_client_init(dir_layout); + if (!loader) + return NULL; + + dir_path = apt_dir_layout_path_get(dir_layout,APT_LAYOUT_CONF_DIR); + + if(unimrcp_client_load(loader,dir_path,CONF_FILE_NAME) == FALSE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Load UniMRCP Client Document"); } - return client; + return loader->client; +} + +/** Create UniMRCP client from XML string configuration */ +MRCP_DECLARE(mrcp_client_t*) unimrcp_client_create2(const char *xmlconfig) +{ + unimrcp_client_loader_t *loader; + + loader = unimrcp_client_init(NULL); + if (!loader) + return NULL; + + if(unimrcp_client_load2(loader,xmlconfig) == FALSE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Process UniMRCP Client Configuration"); + } + + return loader->client; } /** Check whether specified attribute is valid */ static APR_INLINE apt_bool_t is_attr_valid(const apr_xml_attr *attr) { - return (attr && attr->value && attr->value != '\0'); + return (attr && attr->value && *attr->value != '\0'); } /** Check whether specified attribute is enabled (true) */ @@ -172,7 +202,37 @@ static apt_bool_t header_attribs_get(const apr_xml_elem *elem, const apr_xml_att *enable = attr; } } - + + if(is_attr_valid(*id) == FALSE) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Required Attribute in Element <%s>",elem->name); + return FALSE; + } + return TRUE; +} + +/** Get profile attributes such as "id", "enable" and "tag" */ +static apt_bool_t profile_attribs_get(const apr_xml_elem *elem, const apr_xml_attr **id, const apr_xml_attr **enable, const apr_xml_attr **tag) +{ + const apr_xml_attr *attr; + if(!id || !enable || !tag) { + return FALSE; + } + + *id = NULL; + *enable = NULL; + *tag = NULL; + for(attr = elem->attr; attr; attr = attr->next) { + if(strcasecmp(attr->name,"id") == 0) { + *id = attr; + } + else if(strcasecmp(attr->name,"enable") == 0) { + *enable = attr; + } + else if(strcasecmp(attr->name,"tag") == 0) { + *tag = attr; + } + } + if(is_attr_valid(*id) == FALSE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Required Attribute in Element <%s>",elem->name); return FALSE; @@ -220,6 +280,16 @@ static char* unimrcp_client_ip_address_get(unimrcp_client_loader_t *loader, cons } return apr_pstrdup(loader->pool,loader->auto_ip); } + else if(attr && strcasecmp(attr->value,"iface") == 0) { + /* get ip address by network interface name */ + char *ip_addr = DEFAULT_IP_ADDRESS; + if(is_cdata_valid(elem) == TRUE) { + const char *iface_name = cdata_text_get(elem); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Get IP Address by Interface [%s]", iface_name); + apt_ip_get_by_iface(iface_name,&ip_addr,loader->pool); + } + return ip_addr; + } if(is_cdata_valid(elem)) { /* use specified ip address */ @@ -243,7 +313,7 @@ static apt_bool_t unimrcp_client_resource_load(mrcp_resource_loader_t *resource_ if(header_attribs_get(root,&id_attr,&enable_attr) == FALSE) { return FALSE; } - + if(is_attr_enabled(enable_attr) == FALSE) { return TRUE; } @@ -271,7 +341,7 @@ static apt_bool_t unimrcp_client_resource_factory_load(unimrcp_client_loader_t * apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - + resource_factory = mrcp_resource_factory_get(resource_loader); return mrcp_client_resource_factory_register(loader->client,resource_factory); } @@ -309,7 +379,18 @@ static apt_bool_t unimrcp_client_sip_uac_load(unimrcp_client_loader_t *loader, c } else if(strcasecmp(elem->name,"ua-name") == 0) { if(is_cdata_valid(elem) == TRUE) { - config->user_agent_name = cdata_copy(elem,loader->pool); + const apr_xml_attr *attr = NULL; + for(attr = elem->attr; attr; attr = attr->next) { + if(strcasecmp(attr->name,"appendversion") == 0) { + break; + } + } + if(is_attr_enabled(attr)) { + config->user_agent_name = apr_psprintf(loader->pool,"%s "UNI_VERSION_STRING,cdata_text_get(elem)); + } + else { + config->user_agent_name = cdata_copy(elem,loader->pool); + } } } else if(strcasecmp(elem->name,"sdp-origin") == 0) { @@ -337,6 +418,25 @@ static apt_bool_t unimrcp_client_sip_uac_load(unimrcp_client_loader_t *loader, c config->sip_t1x64 = atol(cdata_text_get(elem)); } } + else if(strcasecmp(elem->name,"sip-message-output") == 0) { + if(is_cdata_valid(elem) == TRUE) { + config->tport_log = cdata_bool_get(elem); + } + } + else if(strcasecmp(elem->name,"sip-message-dump") == 0) { + if(is_cdata_valid(elem) == TRUE) { + const char *root_path; + const char *path = cdata_text_get(elem); + if(loader->dir_layout && apr_filepath_root(&root_path,&path,0,loader->pool) == APR_ERELATIVE) + config->tport_dump_file = apt_dir_layout_path_compose( + loader->dir_layout, + APT_LAYOUT_LOG_DIR, + path, + loader->pool); + else + config->tport_dump_file = cdata_copy(elem,loader->pool); + } + } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } @@ -387,7 +487,7 @@ static apt_bool_t unimrcp_client_rtsp_uac_load(unimrcp_client_loader_t *loader, apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - + agent = mrcp_unirtsp_client_agent_create(id,config,loader->pool); return mrcp_client_signaling_agent_register(loader->client,agent); } @@ -413,7 +513,7 @@ static apt_bool_t unimrcp_client_mrcpv2_uac_load(unimrcp_client_loader_t *loader } else if(strcasecmp(elem->name,"offer-new-connection") == 0) { if(is_cdata_valid(elem) == TRUE) { - offer_new_connection = atoi(cdata_text_get(elem)); + offer_new_connection = cdata_bool_get(elem); } } else if(strcasecmp(elem->name,"rx-buffer-size") == 0) { @@ -470,7 +570,7 @@ static apt_bool_t unimrcp_client_media_engine_load(unimrcp_client_loader_t *load apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - + media_engine = mpf_engine_create(id,loader->pool); if(media_engine) { mpf_engine_scheduler_rate_set(media_engine,realtime_rate); @@ -513,8 +613,8 @@ static apt_bool_t unimrcp_client_rtp_factory_load(unimrcp_client_loader_t *loade else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } - + } + if(rtp_ip) { apt_string_set(&rtp_config->ip,rtp_ip); } @@ -569,7 +669,7 @@ static apt_bool_t unimrcp_client_sip_settings_load(unimrcp_client_loader_t *load apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - + if(!settings->server_ip) { settings->server_ip = apr_pstrdup(loader->pool,loader->server_ip); } @@ -618,13 +718,13 @@ static apt_bool_t unimrcp_client_rtsp_settings_load(unimrcp_client_loader_t *loa apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Param %s:%s",name_attr->value,value_attr->value); apr_table_set(settings->resource_map,name_attr->value,value_attr->value); } - } + } } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - + if(!settings->server_ip) { settings->server_ip = apr_pstrdup(loader->pool,loader->server_ip); } @@ -655,6 +755,16 @@ static apt_bool_t unimrcp_client_jb_settings_load(unimrcp_client_loader_t *loade jb->max_playout_delay = atol(cdata_text_get(elem)); } } + else if(strcasecmp(elem->name,"adaptive") == 0) { + if(is_cdata_valid(elem) == TRUE) { + jb->adaptive = (apr_byte_t) atol(cdata_text_get(elem)); + } + } + else if(strcasecmp(elem->name,"time-skew-detection") == 0) { + if(is_cdata_valid(elem) == TRUE) { + jb->time_skew_detection = (apr_byte_t) atol(cdata_text_get(elem)); + } + } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } @@ -737,19 +847,105 @@ static apt_bool_t unimrcp_client_rtp_settings_load(unimrcp_client_loader_t *load else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } return mrcp_client_rtp_settings_register(loader->client,rtp_settings,id); } +/** Create factory of signaling agents */ +static mrcp_sa_factory_t* unimrcp_client_sa_factory_create(unimrcp_client_loader_t *loader, const apr_xml_elem *elem) +{ + mrcp_sa_factory_t *sa_factory = NULL; + mrcp_sig_agent_t *sig_agent; + char *uac_name; + char *state; + char *uac_list_str = apr_pstrdup(loader->pool,cdata_text_get(elem)); + do { + uac_name = apr_strtok(uac_list_str, ",", &state); + if(uac_name) { + sig_agent = mrcp_client_signaling_agent_get(loader->client,uac_name); + if(sig_agent) { + if(!sa_factory) + sa_factory = mrcp_sa_factory_create(loader->pool); + + mrcp_sa_factory_agent_add(sa_factory,sig_agent); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown UAC Name <%s>",uac_name); + } + } + uac_list_str = NULL; /* make sure we pass NULL on subsequent calls of apr_strtok() */ + } + while(uac_name); + return sa_factory; +} + +/** Create factory of MRCPv2 connection agents */ +static mrcp_ca_factory_t* unimrcp_client_ca_factory_create(unimrcp_client_loader_t *loader, const apr_xml_elem *elem) +{ + mrcp_ca_factory_t *ca_factory = NULL; + mrcp_connection_agent_t *agent; + char *name; + char *state; + char *list_str = apr_pstrdup(loader->pool,cdata_text_get(elem)); + do { + name = apr_strtok(list_str, ",", &state); + if(name) { + agent = mrcp_client_connection_agent_get(loader->client,name); + if(agent) { + if(!ca_factory) + ca_factory = mrcp_ca_factory_create(loader->pool); + + mrcp_ca_factory_agent_add(ca_factory,agent); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown MRCPv2-UAC Name <%s>",name); + } + } + list_str = NULL; /* make sure we pass NULL on subsequent calls of apr_strtok() */ + } + while(name); + return ca_factory; +} + +/** Create factory of media engines */ +static mpf_engine_factory_t* unimrcp_client_mpf_factory_create(unimrcp_client_loader_t *loader, const apr_xml_elem *elem) +{ + mpf_engine_factory_t *mpf_factory = NULL; + mpf_engine_t *media_engine; + + char *name; + char *state; + char *list_str = apr_pstrdup(loader->pool,cdata_text_get(elem)); + do { + name = apr_strtok(list_str, ",", &state); + if(name) { + media_engine = mrcp_client_media_engine_get(loader->client,name); + if(media_engine) { + if(!mpf_factory) + mpf_factory = mpf_engine_factory_create(loader->pool); + + mpf_engine_factory_engine_add(mpf_factory,media_engine); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Media Engine Name <%s>",name); + } + } + list_str = NULL; /* make sure we pass NULL on subsequent calls of apr_strtok() */ + } + while(name); + + return mpf_factory; +} + /** Load MRCPv2 profile */ -static apt_bool_t unimrcp_client_mrcpv2_profile_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id) +static apt_bool_t unimrcp_client_mrcpv2_profile_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id, const char *tag) { const apr_xml_elem *elem; mrcp_profile_t *profile; - mrcp_sig_agent_t *sip_agent = NULL; - mrcp_connection_agent_t *mrcpv2_agent = NULL; - mpf_engine_t *media_engine = NULL; + mrcp_sa_factory_t *sa_factory = NULL; + mrcp_ca_factory_t *ca_factory = NULL; + mpf_engine_factory_t *mpf_factory = NULL; mpf_termination_factory_t *rtp_factory = NULL; mpf_rtp_settings_t *rtp_settings = NULL; mrcp_sig_settings_t *sip_settings = NULL; @@ -763,13 +959,13 @@ static apt_bool_t unimrcp_client_mrcpv2_profile_load(unimrcp_client_loader_t *lo } if(strcasecmp(elem->name,"sip-uac") == 0) { - sip_agent = mrcp_client_signaling_agent_get(loader->client,cdata_text_get(elem)); + sa_factory = unimrcp_client_sa_factory_create(loader,elem); } else if(strcasecmp(elem->name,"mrcpv2-uac") == 0) { - mrcpv2_agent = mrcp_client_connection_agent_get(loader->client,cdata_text_get(elem)); + ca_factory = unimrcp_client_ca_factory_create(loader,elem); } else if(strcasecmp(elem->name,"media-engine") == 0) { - media_engine = mrcp_client_media_engine_get(loader->client,cdata_text_get(elem)); + mpf_factory = unimrcp_client_mpf_factory_create(loader,elem); } else if(strcasecmp(elem->name,"rtp-factory") == 0) { rtp_factory = mrcp_client_rtp_factory_get(loader->client,cdata_text_get(elem)); @@ -786,21 +982,25 @@ static apt_bool_t unimrcp_client_mrcpv2_profile_load(unimrcp_client_loader_t *lo } apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCPv2 Profile [%s]",id); - profile = mrcp_client_profile_create( - NULL,sip_agent,mrcpv2_agent, - media_engine,rtp_factory, + profile = mrcp_client_profile_create_ex( + MRCP_VERSION_2,NULL, + sa_factory,ca_factory, + mpf_factory,rtp_factory, rtp_settings,sip_settings, loader->pool); + if(tag) { + mrcp_client_profile_tag_set(profile,tag); + } return mrcp_client_profile_register(loader->client,profile,id); } /** Load MRCPv1 profile */ -static apt_bool_t unimrcp_client_mrcpv1_profile_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id) +static apt_bool_t unimrcp_client_mrcpv1_profile_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root, const char *id, const char *tag) { const apr_xml_elem *elem; mrcp_profile_t *profile; - mrcp_sig_agent_t *rtsp_agent = NULL; - mpf_engine_t *media_engine = NULL; + mrcp_sa_factory_t *sa_factory = NULL; + mpf_engine_factory_t *mpf_factory = NULL; mpf_termination_factory_t *rtp_factory = NULL; mpf_rtp_settings_t *rtp_settings = NULL; mrcp_sig_settings_t *rtsp_settings = NULL; @@ -814,10 +1014,10 @@ static apt_bool_t unimrcp_client_mrcpv1_profile_load(unimrcp_client_loader_t *lo } if(strcasecmp(elem->name,"rtsp-uac") == 0) { - rtsp_agent = mrcp_client_signaling_agent_get(loader->client,cdata_text_get(elem)); + sa_factory = unimrcp_client_sa_factory_create(loader,elem); } else if(strcasecmp(elem->name,"media-engine") == 0) { - media_engine = mrcp_client_media_engine_get(loader->client,cdata_text_get(elem)); + mpf_factory = unimrcp_client_mpf_factory_create(loader,elem); } else if(strcasecmp(elem->name,"rtp-factory") == 0) { rtp_factory = mrcp_client_rtp_factory_get(loader->client,cdata_text_get(elem)); @@ -834,11 +1034,15 @@ static apt_bool_t unimrcp_client_mrcpv1_profile_load(unimrcp_client_loader_t *lo } apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCPv1 Profile [%s]",id); - profile = mrcp_client_profile_create( - NULL,rtsp_agent,NULL, - media_engine,rtp_factory, + profile = mrcp_client_profile_create_ex( + MRCP_VERSION_1, + NULL,sa_factory,NULL, + mpf_factory,rtp_factory, rtp_settings,rtsp_settings, loader->pool); + if(tag) { + mrcp_client_profile_tag_set(profile,tag); + } return mrcp_client_profile_register(loader->client,profile,id); } @@ -897,7 +1101,7 @@ static apt_bool_t unimrcp_client_components_load(unimrcp_client_loader_t *loader unimrcp_client_resource_factory_load(loader,elem); continue; } - + /* get common "id" and "enable" attributes */ if(header_attribs_get(elem,&id_attr,&enable_attr) == FALSE) { /* invalid id */ @@ -927,7 +1131,7 @@ static apt_bool_t unimrcp_client_components_load(unimrcp_client_loader_t *loader else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } return TRUE; } @@ -964,7 +1168,7 @@ static apt_bool_t unimrcp_client_settings_load(unimrcp_client_loader_t *loader, else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } return TRUE; } @@ -974,12 +1178,14 @@ static apt_bool_t unimrcp_client_profiles_load(unimrcp_client_loader_t *loader, const apr_xml_elem *elem; const apr_xml_attr *id_attr; const apr_xml_attr *enable_attr; + const apr_xml_attr *tag_attr; const char *id; + const char *tag; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Profiles"); for(elem = root->first_child; elem; elem = elem->next) { /* get common "id" and "enable" attributes */ - if(header_attribs_get(elem,&id_attr,&enable_attr) == FALSE) { + if(profile_attribs_get(elem,&id_attr,&enable_attr,&tag_attr) == FALSE) { /* invalid id */ continue; } @@ -988,17 +1194,58 @@ static apt_bool_t unimrcp_client_profiles_load(unimrcp_client_loader_t *loader, continue; } id = apr_pstrdup(loader->pool,id_attr->value); + tag = tag_attr ? apr_pstrdup(loader->pool,tag_attr->value) : NULL; if(strcasecmp(elem->name,"mrcpv2-profile") == 0) { - unimrcp_client_mrcpv2_profile_load(loader,elem,id); + unimrcp_client_mrcpv2_profile_load(loader,elem,id,tag); } else if(strcasecmp(elem->name,"mrcpv1-profile") == 0) { - unimrcp_client_mrcpv1_profile_load(loader,elem,id); + unimrcp_client_mrcpv1_profile_load(loader,elem,id,tag); } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } + return TRUE; +} + +/** Load misc parameters */ +static apt_bool_t unimrcp_client_misc_load(unimrcp_client_loader_t *loader, const apr_xml_elem *root) +{ + const apr_xml_elem *elem; + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Misc Parameters"); + for(elem = root->first_child; elem; elem = elem->next) { + if(strcasecmp(elem->name,"sofiasip-logger") == 0) { + char *logger_list_str; + char *logger_name; + char *state; + apr_xml_attr *attr; + apt_bool_t redirect = FALSE; + const char *loglevel_str = NULL; + for(attr = elem->attr; attr; attr = attr->next) { + if(strcasecmp(attr->name,"redirect") == 0) { + if(attr->value && strcasecmp(attr->value,"true") == 0) + redirect = TRUE; + } + else if(strcasecmp(attr->name,"loglevel") == 0) { + loglevel_str = attr->value; + } + } + + logger_list_str = apr_pstrdup(loader->pool,cdata_text_get(elem)); + do { + logger_name = apr_strtok(logger_list_str, ",", &state); + if(logger_name) { + mrcp_sofiasip_client_logger_init(logger_name,loglevel_str,redirect); + } + logger_list_str = NULL; /* make sure we pass NULL on subsequent calls of apr_strtok() */ + } + while(logger_name); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); + } + } return TRUE; } @@ -1027,30 +1274,15 @@ static apr_xml_doc* unimrcp_client_doc_parse(const char *file_path, apr_pool_t * return xml_doc; } -/** Load UniMRCP client */ -static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const char *dir_path, const char *file_name, apr_pool_t *pool) +/** Process parsed XML document */ +static apt_bool_t unimrcp_client_doc_process(unimrcp_client_loader_t *loader, const char *dir_path, apr_xml_doc *doc, apr_pool_t *pool) { - apr_xml_doc *doc; const apr_xml_elem *elem; const apr_xml_elem *root; const apr_xml_attr *attr; - const char *file_path; const char *version = NULL; const char *subfolder = NULL; - if(!dir_path || !file_name) { - return FALSE; - } - - if(*dir_path == '\0') { - file_path = file_name; - } - else { - file_path = apr_psprintf(pool,"%s/%s",dir_path,file_name); - } - - /* Parse XML document */ - doc = unimrcp_client_doc_parse(file_path,pool); if(!doc) { return FALSE; } @@ -1059,7 +1291,7 @@ static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const cha /* Match document name */ if(!root || strcasecmp(root->name,"unimrcpclient") != 0) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Document <%s>",root->name); + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Document <%s>",root ? root->name : "null"); return FALSE; } @@ -1095,31 +1327,90 @@ static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const cha else if(strcasecmp(elem->name,"profiles") == 0) { unimrcp_client_profiles_load(loader,elem); } + else if(strcasecmp(elem->name,"misc") == 0) { + unimrcp_client_misc_load(loader,elem); + } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - if(subfolder && subfolder != '\0') { + if(subfolder && *subfolder != '\0') { apr_dir_t *dir; apr_finfo_t finfo; apr_status_t rv; + char *subdir_path; - dir_path = apr_psprintf(pool,"%s/%s",dir_path,subfolder); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Enter Directory [%s]",dir_path); - rv = apr_dir_open(&dir,dir_path,pool); - if(rv == APR_SUCCESS) { - while(apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { - if(apr_fnmatch("*.xml", finfo.name, 0) == APR_SUCCESS) { - unimrcp_client_load(loader,dir_path,finfo.name,pool); - } - } - apr_dir_close(dir); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Leave Directory [%s]",dir_path); + if (!dir_path) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Attempt to Process Subdirectory when " + "Creating from Config String"); + return TRUE; } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No Such Directory %s",dir_path); + + if(apr_filepath_merge(&subdir_path,dir_path,subfolder,APR_FILEPATH_NATIVE,pool) == APR_SUCCESS) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Enter Directory [%s]",subdir_path); + rv = apr_dir_open(&dir,subdir_path,pool); + if(rv == APR_SUCCESS) { + while(apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { + if(apr_fnmatch("*.xml", finfo.name, 0) == APR_SUCCESS) { + unimrcp_client_load(loader,subdir_path,finfo.name); + } + } + apr_dir_close(dir); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Leave Directory [%s]",dir_path); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No Such Directory %s",dir_path); + } } } return TRUE; } + +/** Load UniMRCP client from file */ +static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const char *dir_path, const char *file_name) +{ + apr_pool_t *pool = loader->pool; + apr_xml_doc *doc; + char *file_path; + + if(!dir_path || !file_name) { + return FALSE; + } + + if(apr_filepath_merge(&file_path,dir_path,file_name,APR_FILEPATH_NATIVE,pool) != APR_SUCCESS) { + return FALSE; + } + + /* Parse XML document */ + doc = unimrcp_client_doc_parse(file_path,pool); + return unimrcp_client_doc_process(loader, dir_path, doc, pool); +} + +/** Read configuration from string */ +static apt_bool_t unimrcp_client_load2(unimrcp_client_loader_t *loader, const char *xmlconfig) +{ + apr_pool_t *pool = loader->pool; + apr_xml_parser *parser; + apr_xml_doc *xml_doc; + char errbuf[4096]; + apr_status_t rv; + + parser = apr_xml_parser_create(pool); + if (!parser) return FALSE; + rv = apr_xml_parser_feed(parser, xmlconfig, strlen(xmlconfig)); + if (rv != APR_SUCCESS) { + apr_xml_parser_geterror(parser, errbuf, sizeof(errbuf)); + apt_log(APT_LOG_MARK, APT_PRIO_ERROR, "Error parsing XML configuration: %d %pm: %s", + rv, &rv, errbuf); + return FALSE; + } + rv = apr_xml_parser_done(parser, &xml_doc); + if (rv != APR_SUCCESS) { + apr_xml_parser_geterror(parser, errbuf, sizeof(errbuf)); + apt_log(APT_LOG_MARK, APT_PRIO_ERROR, "Error parsing XML configuration: %d %pm: %s", + rv, &rv, errbuf); + return FALSE; + } + return unimrcp_client_doc_process(loader, NULL, xml_doc, pool); +} diff --git a/libs/unimrcp/platforms/libunimrcp-server/Makefile.am b/libs/unimrcp/platforms/libunimrcp-server/Makefile.am index 98ae5e5320..1226d61813 100644 --- a/libs/unimrcp/platforms/libunimrcp-server/Makefile.am +++ b/libs/unimrcp/platforms/libunimrcp-server/Makefile.am @@ -1,36 +1,11 @@ -MAINTAINERCLEANFILES = Makefile.in - AM_CPPFLAGS = -I$(top_srcdir)/platforms/libunimrcp-server/include \ - -I$(unimrcp_srcdir)/modules/mrcp-sofiasip/include \ - -I$(top_srcdir)/modules/mrcp-unirtsp/include \ - -I$(top_srcdir)/libs/mrcp-server/include \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - -I$(top_srcdir)/build \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_SERVERLIB_INCLUDES) lib_LTLIBRARIES = libunimrcpserver.la include_HEADERS = include/unimrcp_server.h - libunimrcpserver_la_SOURCES = src/unimrcp_server.c +libunimrcpserver_la_LIBADD = $(UNIMRCP_SERVERLIB_LIBS) +libunimrcpserver_la_LDFLAGS = $(UNIMRCP_SERVERLIB_OPTS) -libunimrcpserver_la_LIBADD = $(top_builddir)/modules/mrcp-sofiasip/libmrcpsofiasip.la \ - $(top_builddir)/modules/mrcp-unirtsp/libmrcpunirtsp.la \ - $(top_builddir)/libs/mrcp-server/libmrcpserver.la \ - $(top_builddir)/libs/mrcp-signaling/libmrcpsignaling.la \ - $(top_builddir)/libs/mrcpv2-transport/libmrcpv2transport.la \ - $(top_builddir)/libs/mrcp-engine/libmrcpengine.la \ - $(top_builddir)/libs/mrcp/libmrcp.la \ - $(top_builddir)/libs/mpf/libmpf.la \ - $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) $(UNIMRCP_SOFIA_LIBS) -lm - -libunimrcpserver_la_LDFLAGS = $(UNI_LT_VERSION) +include $(top_srcdir)/build/rules/uniserverlib.am diff --git a/libs/unimrcp/platforms/libunimrcp-server/include/unimrcp_server.h b/libs/unimrcp/platforms/libunimrcp-server/include/unimrcp_server.h index c66fb74e56..aaf81d387e 100644 --- a/libs/unimrcp/platforms/libunimrcp-server/include/unimrcp_server.h +++ b/libs/unimrcp/platforms/libunimrcp-server/include/unimrcp_server.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: unimrcp_server.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: unimrcp_server.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef UNIMRCP_SERVER_H diff --git a/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.2008.vcproj b/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.2008.vcproj deleted file mode 100644 index 1982d77090..0000000000 --- a/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.2008.vcproj +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj b/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj new file mode 100644 index 0000000000..a64579d7c1 --- /dev/null +++ b/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C98AF157-352E-4737-BD30-A24E2647F5AE} + libunimrcpserver + Win32Proj + + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + true + + + StaticLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + + + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + + + + + X64 + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + $(ProjectRootDir)modules\mrcp-sofiasip\include;$(ProjectRootDir)modules\mrcp-unirtsp\include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + {18b1f35a-10f8-4287-9b37-2d10501b0b38} + false + + + {746f3632-5bb2-4570-9453-31d6d58a7d8e} + false + + + {deb01acb-d65f-4a62-aed9-58c1054499e9} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj.filters b/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj.filters new file mode 100644 index 0000000000..67b6af97a6 --- /dev/null +++ b/libs/unimrcp/platforms/libunimrcp-server/libunimrcpserver.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {c164436d-b3de-474f-99bc-6b2ca1a4c879} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + include + + + include + + + include + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c b/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c index d7b23865c2..ee03dba003 100644 --- a/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c +++ b/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c @@ -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,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: unimrcp_server.c 1711 2010-05-25 17:54:02Z achaloyan $ + * $Id: unimrcp_server.c 2231 2014-11-12 01:32:03Z achaloyan@gmail.com $ */ #include #include #include #include "uni_version.h" +#include "uni_revision.h" #include "unimrcp_server.h" #include "mrcp_resource_loader.h" #include "mpf_engine.h" @@ -32,7 +33,6 @@ #include "apt_log.h" #define CONF_FILE_NAME "unimrcpserver.xml" -#define DEFAULT_PLUGIN_DIR_PATH "../plugin" #ifdef WIN32 #define DEFAULT_PLUGIN_EXT "dll" #else @@ -86,7 +86,7 @@ MRCP_DECLARE(mrcp_server_t*) unimrcp_server_start(apt_dir_layout_t *dir_layout) return NULL; } - apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"UniMRCP Server ["UNI_VERSION_STRING"]"); + apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"UniMRCP Server ["UNI_VERSION_STRING"] [r"UNI_REVISION_STRING"]"); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"APR ["APR_VERSION_STRING"]"); server = mrcp_server_create(dir_layout); if(!server) { @@ -118,7 +118,7 @@ MRCP_DECLARE(apt_bool_t) unimrcp_server_shutdown(mrcp_server_t *server) /** Check whether specified attribute is valid */ static APR_INLINE apt_bool_t is_attr_valid(const apr_xml_attr *attr) { - return (attr && attr->value && attr->value != '\0'); + return (attr && attr->value && *attr->value != '\0'); } /** Check whether specified attribute is enabled (true) */ @@ -172,7 +172,7 @@ static apt_bool_t header_attribs_get(const apr_xml_elem *elem, const apr_xml_att *enable = attr; } } - + if(is_attr_valid(*id) == FALSE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Required Attribute in Element <%s>",elem->name); return FALSE; @@ -220,6 +220,16 @@ static char* unimrcp_server_ip_address_get(unimrcp_server_loader_t *loader, cons } return apr_pstrdup(loader->pool,loader->auto_ip); } + else if(attr && strcasecmp(attr->value,"iface") == 0) { + /* get ip address by network interface name */ + char *ip_addr = DEFAULT_IP_ADDRESS; + if(is_cdata_valid(elem) == TRUE) { + const char *iface_name = cdata_text_get(elem); + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Get IP Address by Interface [%s]", iface_name); + apt_ip_get_by_iface(iface_name,&ip_addr,loader->pool); + } + return ip_addr; + } if(is_cdata_valid(elem)) { /* use provided ip address */ @@ -269,7 +279,7 @@ static apt_bool_t unimrcp_server_resource_factory_load(unimrcp_server_loader_t * apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } } - + resource_factory = mrcp_resource_factory_get(resource_loader); return mrcp_server_resource_factory_register(loader->server,resource_factory); } @@ -307,7 +317,18 @@ static apt_bool_t unimrcp_server_sip_uas_load(unimrcp_server_loader_t *loader, c } else if(strcasecmp(elem->name,"ua-name") == 0) { if(is_cdata_valid(elem) == TRUE) { - config->user_agent_name = cdata_copy(elem,loader->pool); + const apr_xml_attr *attr = NULL; + for(attr = elem->attr; attr; attr = attr->next) { + if(strcasecmp(attr->name,"appendversion") == 0) { + break; + } + } + if(is_attr_enabled(attr)) { + config->user_agent_name = apr_psprintf(loader->pool,"%s "UNI_VERSION_STRING,cdata_text_get(elem)); + } + else { + config->user_agent_name = cdata_copy(elem,loader->pool); + } } } else if(strcasecmp(elem->name,"sdp-origin") == 0) { @@ -340,6 +361,25 @@ static apt_bool_t unimrcp_server_sip_uas_load(unimrcp_server_loader_t *loader, c config->sip_t1x64 = atol(cdata_text_get(elem)); } } + else if(strcasecmp(elem->name,"sip-message-output") == 0) { + if(is_cdata_valid(elem) == TRUE) { + config->tport_log = cdata_bool_get(elem); + } + } + else if(strcasecmp(elem->name,"sip-message-dump") == 0) { + if(is_cdata_valid(elem) == TRUE) { + const char *root_path; + const char *path = cdata_text_get(elem); + if(loader->dir_layout && apr_filepath_root(&root_path,&path,0,loader->pool) == APR_ERELATIVE) + config->tport_dump_file = apt_dir_layout_path_compose( + loader->dir_layout, + APT_LAYOUT_LOG_DIR, + path, + loader->pool); + else + config->tport_dump_file = cdata_copy(elem,loader->pool); + } + } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } @@ -547,8 +587,8 @@ static apt_bool_t unimrcp_server_rtp_factory_load(unimrcp_server_loader_t *loade else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } - + } + if(rtp_ip) { apt_string_set(&rtp_config->ip,rtp_ip); } @@ -571,10 +611,11 @@ static apt_bool_t unimrcp_server_plugin_load(unimrcp_server_loader_t *loader, co { mrcp_engine_t *engine; mrcp_engine_config_t *config; + char *plugin_file_name; + char *plugin_path; const char *plugin_id = NULL; const char *plugin_name = NULL; const char *plugin_ext = NULL; - const char *plugin_path = NULL; apt_bool_t plugin_enabled = TRUE; const apr_xml_attr *attr; for(attr = root->attr; attr; attr = attr->next) { @@ -599,7 +640,7 @@ static apt_bool_t unimrcp_server_plugin_load(unimrcp_server_loader_t *loader, co apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing plugin id or name"); return FALSE; } - + if(!plugin_enabled) { /* disabled plugin, just skip it */ return TRUE; @@ -609,13 +650,11 @@ static apt_bool_t unimrcp_server_plugin_load(unimrcp_server_loader_t *loader, co plugin_ext = DEFAULT_PLUGIN_EXT; } - if(*loader->dir_layout->plugin_dir_path == '\0') { - plugin_path = apr_psprintf(loader->pool,"%s.%s", - plugin_name,plugin_ext); - } - else { - plugin_path = apr_psprintf(loader->pool,"%s/%s.%s", - loader->dir_layout->plugin_dir_path,plugin_name,plugin_ext); + plugin_file_name = apr_psprintf(loader->pool,"%s.%s",plugin_name,plugin_ext); + plugin_path = apt_dir_layout_path_compose(loader->dir_layout,APT_LAYOUT_PLUGIN_DIR,plugin_file_name,loader->pool); + if(!plugin_path) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to compose plugin path %s",plugin_file_name); + return FALSE; } config = mrcp_engine_config_alloc(loader->pool); @@ -651,10 +690,6 @@ static apt_bool_t unimrcp_server_plugin_factory_load(unimrcp_server_loader_t *lo { const apr_xml_elem *elem; - if(!loader->dir_layout->plugin_dir_path) { - loader->dir_layout->plugin_dir_path = DEFAULT_PLUGIN_DIR_PATH; - } - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Plugin Factory"); for(elem = root->first_child; elem; elem = elem->next) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Element <%s>",elem->name); @@ -691,6 +726,16 @@ static apt_bool_t unimrcp_server_jb_settings_load(unimrcp_server_loader_t *loade jb->max_playout_delay = atol(cdata_text_get(elem)); } } + else if(strcasecmp(elem->name,"adaptive") == 0) { + if(is_cdata_valid(elem) == TRUE) { + jb->adaptive = (apr_byte_t) atol(cdata_text_get(elem)); + } + } + else if(strcasecmp(elem->name,"time-skew-detection") == 0) { + if(is_cdata_valid(elem) == TRUE) { + jb->time_skew_detection = (apr_byte_t) atol(cdata_text_get(elem)); + } + } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } @@ -780,7 +825,7 @@ static apt_bool_t unimrcp_server_rtp_settings_load(unimrcp_server_loader_t *load else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } return mrcp_server_rtp_settings_register(loader->server,rtp_settings,id); } @@ -850,6 +895,7 @@ static apt_bool_t unimrcp_server_mrcpv2_profile_load(unimrcp_server_loader_t *lo apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCPv2 Profile [%s]",id); profile = mrcp_server_profile_create( id, + MRCP_VERSION_2, NULL, sip_agent, mrcpv2_agent, @@ -902,6 +948,7 @@ static apt_bool_t unimrcp_server_mrcpv1_profile_load(unimrcp_server_loader_t *lo apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCPv1 Profile [%s]",id); profile = mrcp_server_profile_create( id, + MRCP_VERSION_1, NULL, rtsp_agent, NULL, @@ -1024,7 +1071,7 @@ static apt_bool_t unimrcp_server_settings_load(unimrcp_server_loader_t *loader, else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } return TRUE; } @@ -1058,7 +1105,47 @@ static apt_bool_t unimrcp_server_profiles_load(unimrcp_server_loader_t *loader, else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } - } + } + return TRUE; +} + +/** Load misc parameters */ +static apt_bool_t unimrcp_server_misc_load(unimrcp_server_loader_t *loader, const apr_xml_elem *root) +{ + const apr_xml_elem *elem; + apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Loading Misc Parameters"); + for(elem = root->first_child; elem; elem = elem->next) { + if(strcasecmp(elem->name,"sofiasip-logger") == 0) { + char *logger_list_str; + char *logger_name; + char *state; + apr_xml_attr *attr; + apt_bool_t redirect = FALSE; + const char *loglevel_str = NULL; + for(attr = elem->attr; attr; attr = attr->next) { + if(strcasecmp(attr->name,"redirect") == 0) { + if(attr->value && strcasecmp(attr->value,"true") == 0) + redirect = TRUE; + } + else if(strcasecmp(attr->name,"loglevel") == 0) { + loglevel_str = attr->value; + } + } + + logger_list_str = apr_pstrdup(loader->pool,cdata_text_get(elem)); + do { + logger_name = apr_strtok(logger_list_str, ",", &state); + if(logger_name) { + mrcp_sofiasip_server_logger_init(logger_name,loglevel_str,redirect); + } + logger_list_str = NULL; /* make sure we pass NULL on subsequent calls of apr_strtok() */ + } + while(logger_name); + } + else { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); + } + } return TRUE; } @@ -1082,7 +1169,7 @@ static apr_xml_doc* unimrcp_server_doc_parse(const char *file_path, apr_pool_t * apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Parse Config File [%s]",file_path); xml_doc = NULL; } - + apr_file_close(fd); return xml_doc; } @@ -1113,7 +1200,7 @@ static apt_bool_t unimrcp_server_load(mrcp_server_t *mrcp_server, apt_dir_layout /* Match document name */ if(!root || strcasecmp(root->name,"unimrcpserver") != 0) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Document <%s>",root->name); + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Document <%s>",root ? root->name : "null"); return FALSE; } @@ -1153,6 +1240,9 @@ static apt_bool_t unimrcp_server_load(mrcp_server_t *mrcp_server, apt_dir_layout else if(strcasecmp(elem->name,"profiles") == 0) { unimrcp_server_profiles_load(loader,elem); } + else if(strcasecmp(elem->name,"misc") == 0) { + unimrcp_server_misc_load(loader,elem); + } else { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); } diff --git a/libs/unimrcp/platforms/umc/Makefile.am b/libs/unimrcp/platforms/umc/Makefile.am index 7c3de34aac..5b41d43e2d 100644 --- a/libs/unimrcp/platforms/umc/Makefile.am +++ b/libs/unimrcp/platforms/umc/Makefile.am @@ -1,20 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(unimrcp_srcdir)/platforms/umc/include \ - -I$(top_srcdir)/platforms/libunimrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = -I$(top_srcdir)/platforms/umc/include \ + $(UNIMRCP_CLIENTAPP_INCLUDES) bin_PROGRAMS = umc + umc_SOURCES = src/main.cpp \ src/umcconsole.cpp \ src/umcframework.cpp \ @@ -32,9 +20,7 @@ umc_SOURCES = src/main.cpp \ src/setparamsession.cpp \ src/verifierscenario.cpp \ src/verifiersession.cpp - -umc_LDADD = $(top_builddir)/platforms/libunimrcp-client/libunimrcpclient.la +umc_LDADD = $(UNIMRCP_CLIENTAPP_LIBS) +umc_LDFLAGS = $(UNIMRCP_CLIENTAPP_OPTS) -if ISMAC -umc_LDFLAGS = -framework CoreFoundation -framework SystemConfiguration -endif +include $(top_srcdir)/build/rules/uniclientapp.am diff --git a/libs/unimrcp/platforms/umc/include/dtmfscenario.h b/libs/unimrcp/platforms/umc/include/dtmfscenario.h index 45a5430cf7..7847ab3237 100644 --- a/libs/unimrcp/platforms/umc/include/dtmfscenario.h +++ b/libs/unimrcp/platforms/umc/include/dtmfscenario.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: dtmfscenario.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: dtmfscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef DTMF_SCENARIO_H diff --git a/libs/unimrcp/platforms/umc/include/dtmfsession.h b/libs/unimrcp/platforms/umc/include/dtmfsession.h index e0a3f7ccd0..4093fff43c 100644 --- a/libs/unimrcp/platforms/umc/include/dtmfsession.h +++ b/libs/unimrcp/platforms/umc/include/dtmfsession.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.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: dtmfsession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef DTMF_SESSION_H @@ -45,7 +45,7 @@ protected: mrcp_message_t* CreateRecognizeRequest(mrcp_channel_t* pMrcpChannel); - bool ParseNLSMLResult(mrcp_message_t* pMrcpMessage) const; + static bool ParseNLSMLResult(mrcp_message_t* pMrcpMessage); /* ============================ HANDLERS =================================== */ virtual bool OnSessionTerminate(mrcp_sig_status_code_e status); diff --git a/libs/unimrcp/platforms/umc/include/recogscenario.h b/libs/unimrcp/platforms/umc/include/recogscenario.h index fc20c10757..6d40ebfe9e 100644 --- a/libs/unimrcp/platforms/umc/include/recogscenario.h +++ b/libs/unimrcp/platforms/umc/include/recogscenario.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.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: recogscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RECOG_SCENARIO_H @@ -41,6 +41,7 @@ public: /* ============================ ACCESSORS ================================== */ const char* GetContentType() const; const char* GetContent() const; + apr_size_t GetContentLength() const; const char* GetAudioSource() const; /* ============================ INQUIRIES ================================== */ @@ -58,6 +59,7 @@ protected: bool m_Recognize; const char* m_ContentType; const char* m_Content; + apr_size_t m_ContentLength; const char* m_AudioSource; }; @@ -72,6 +74,11 @@ inline const char* RecogScenario::GetContent() const return m_Content; } +inline apr_size_t RecogScenario::GetContentLength() const +{ + return m_ContentLength; +} + inline const char* RecogScenario::GetAudioSource() const { return m_AudioSource; diff --git a/libs/unimrcp/platforms/umc/include/recogsession.h b/libs/unimrcp/platforms/umc/include/recogsession.h index 5cc44404e0..02ba2a7f1d 100644 --- a/libs/unimrcp/platforms/umc/include/recogsession.h +++ b/libs/unimrcp/platforms/umc/include/recogsession.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: recogsession.h 1587 2010-03-12 19:40:02Z achaloyan $ + * $Id: recogsession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RECOG_SESSION_H @@ -48,7 +48,7 @@ protected: mrcp_message_t* CreateDefineGrammarRequest(mrcp_channel_t* pMrcpChannel); mrcp_message_t* CreateRecognizeRequest(mrcp_channel_t* pMrcpChannel); - bool ParseNLSMLResult(mrcp_message_t* pMrcpMessage) const; + static bool ParseNLSMLResult(mrcp_message_t* pMrcpMessage); FILE* GetAudioIn(const mpf_codec_descriptor_t* pDescriptor, apr_pool_t* pool) const; /* ============================ HANDLERS =================================== */ diff --git a/libs/unimrcp/platforms/umc/include/recorderscenario.h b/libs/unimrcp/platforms/umc/include/recorderscenario.h index cc27b0a1e7..4a1f283c23 100644 --- a/libs/unimrcp/platforms/umc/include/recorderscenario.h +++ b/libs/unimrcp/platforms/umc/include/recorderscenario.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: recorderscenario.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: recorderscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RECORDER_SCENARIO_H diff --git a/libs/unimrcp/platforms/umc/include/recordersession.h b/libs/unimrcp/platforms/umc/include/recordersession.h index 4f4200ef1c..31d53c8a45 100644 --- a/libs/unimrcp/platforms/umc/include/recordersession.h +++ b/libs/unimrcp/platforms/umc/include/recordersession.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.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: recordersession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef RECORDER_SESSION_H diff --git a/libs/unimrcp/platforms/umc/include/setparamscenario.h b/libs/unimrcp/platforms/umc/include/setparamscenario.h index 75df62c6b2..bc1ad0ed89 100644 --- a/libs/unimrcp/platforms/umc/include/setparamscenario.h +++ b/libs/unimrcp/platforms/umc/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: setparamscenario.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: setparamscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef SETPARAM_SCENARIO_H diff --git a/libs/unimrcp/platforms/umc/include/setparamsession.h b/libs/unimrcp/platforms/umc/include/setparamsession.h index 916a86ee40..16754f309f 100644 --- a/libs/unimrcp/platforms/umc/include/setparamsession.h +++ b/libs/unimrcp/platforms/umc/include/setparamsession.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.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: setparamsession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef SETPARAM_SESSION_H diff --git a/libs/unimrcp/platforms/umc/include/synthscenario.h b/libs/unimrcp/platforms/umc/include/synthscenario.h index 921a857905..120afc7854 100644 --- a/libs/unimrcp/platforms/umc/include/synthscenario.h +++ b/libs/unimrcp/platforms/umc/include/synthscenario.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: synthscenario.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: synthscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef SYNTH_SCENARIO_H diff --git a/libs/unimrcp/platforms/umc/include/synthsession.h b/libs/unimrcp/platforms/umc/include/synthsession.h index 94a592c86d..d980431af8 100644 --- a/libs/unimrcp/platforms/umc/include/synthsession.h +++ b/libs/unimrcp/platforms/umc/include/synthsession.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.h 1586 2010-03-12 19:39:02Z achaloyan $ + * $Id: synthsession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef SYNTH_SESSION_H diff --git a/libs/unimrcp/platforms/umc/include/umcconsole.h b/libs/unimrcp/platforms/umc/include/umcconsole.h index 23bf6b1882..06dc221309 100644 --- a/libs/unimrcp/platforms/umc/include/umcconsole.h +++ b/libs/unimrcp/platforms/umc/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: umcconsole.h 1525 2010-02-16 14:58:56Z achaloyan $ + * $Id: umcconsole.h 2197 2014-10-16 01:34:19Z achaloyan@gmail.com $ */ #ifndef UMC_CONSOLE_H @@ -42,19 +42,24 @@ protected: bool LoadOptions(int argc, const char * const *argv, apr_pool_t *pool); bool RunCmdLine(); bool ProcessCmdLine(char* pCmdLine); - void Usage() const; + static void Usage(); private: /* ============================ DATA ======================================= */ struct UmcOptions { const char* m_RootDirPath; + const char* m_DirLayoutConf; const char* m_LogPriority; const char* m_LogOutput; + + UmcOptions() : + m_RootDirPath(NULL), m_DirLayoutConf(NULL), + m_LogPriority(NULL), m_LogOutput(NULL) {} }; - UmcOptions m_Options; - UmcFramework* m_pFramework; + UmcOptions m_Options; + UmcFramework* m_pFramework; }; #endif /* UMC_CONSOLE_H */ diff --git a/libs/unimrcp/platforms/umc/include/umcframework.h b/libs/unimrcp/platforms/umc/include/umcframework.h index ef803cb184..fbbb47c441 100644 --- a/libs/unimrcp/platforms/umc/include/umcframework.h +++ b/libs/unimrcp/platforms/umc/include/umcframework.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: umcframework.h 1585 2010-03-12 19:12:05Z achaloyan $ + * $Id: umcframework.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef UMC_FRAMEWORK_H diff --git a/libs/unimrcp/platforms/umc/include/umcscenario.h b/libs/unimrcp/platforms/umc/include/umcscenario.h index 2425fc968e..c3f3b03cc6 100644 --- a/libs/unimrcp/platforms/umc/include/umcscenario.h +++ b/libs/unimrcp/platforms/umc/include/umcscenario.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: umcscenario.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: umcscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef UMC_SCENARIO_H @@ -65,11 +65,12 @@ protected: bool LoadCapabilities(const apr_xml_elem* pElem, apr_pool_t* pool); bool LoadRtpTermination(const apr_xml_elem* pElem, apr_pool_t* pool); + const char* LoadFileContent(const char* pFileName, apr_size_t& size, apr_pool_t* pool) const; const char* LoadFileContent(const char* pFileName, apr_pool_t* pool) const; - int ParseRates(const char* pStr, apr_pool_t* pool) const; + static int ParseRates(const char* pStr, apr_pool_t* pool); /* ============================ INQUIRIES ================================== */ - bool IsElementEnabled(const apr_xml_elem* pElem) const; + static bool IsElementEnabled(const apr_xml_elem* pElem); /* ============================ DATA ======================================= */ const char* m_pName; @@ -119,4 +120,10 @@ inline bool UmcScenario::IsDiscoveryEnabled() const } +inline const char* UmcScenario::LoadFileContent(const char* pFileName, apr_pool_t* pool) const +{ + apr_size_t dummy; + return LoadFileContent(pFileName, dummy, pool); +} + #endif /* UMC_SCENARIO_H */ diff --git a/libs/unimrcp/platforms/umc/include/umcsession.h b/libs/unimrcp/platforms/umc/include/umcsession.h index 308e1704ff..a265d2a546 100644 --- a/libs/unimrcp/platforms/umc/include/umcsession.h +++ b/libs/unimrcp/platforms/umc/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: umcsession.h 1585 2010-03-12 19:12:05Z achaloyan $ + * $Id: umcsession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef UMC_SESSION_H diff --git a/libs/unimrcp/platforms/umc/include/verifierscenario.h b/libs/unimrcp/platforms/umc/include/verifierscenario.h index 52856b077a..b4b49a382b 100644 --- a/libs/unimrcp/platforms/umc/include/verifierscenario.h +++ b/libs/unimrcp/platforms/umc/include/verifierscenario.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.h 1775 2010-08-26 18:23:38Z achaloyan $ + * $Id: verifierscenario.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef VERIFIER_SCENARIO_H diff --git a/libs/unimrcp/platforms/umc/include/verifiersession.h b/libs/unimrcp/platforms/umc/include/verifiersession.h index 856a889f91..777a58507a 100644 --- a/libs/unimrcp/platforms/umc/include/verifiersession.h +++ b/libs/unimrcp/platforms/umc/include/verifiersession.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.h 1776 2010-08-27 16:36:38Z achaloyan $ + * $Id: verifiersession.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef VERIFIER_SESSION_H diff --git a/libs/unimrcp/platforms/umc/src/dtmfscenario.cpp b/libs/unimrcp/platforms/umc/src/dtmfscenario.cpp index d61b528071..190c9a87f1 100644 --- a/libs/unimrcp/platforms/umc/src/dtmfscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/dtmfscenario.cpp @@ -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 diff --git a/libs/unimrcp/platforms/umc/src/dtmfsession.cpp b/libs/unimrcp/platforms/umc/src/dtmfsession.cpp index 8ce8f9767f..b10b13946c 100644 --- a/libs/unimrcp/platforms/umc/src/dtmfsession.cpp +++ b/libs/unimrcp/platforms/umc/src/dtmfsession.cpp @@ -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; } diff --git a/libs/unimrcp/platforms/umc/src/main.cpp b/libs/unimrcp/platforms/umc/src/main.cpp index 08983a20ae..d06873989e 100644 --- a/libs/unimrcp/platforms/umc/src/main.cpp +++ b/libs/unimrcp/platforms/umc/src/main.cpp @@ -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" diff --git a/libs/unimrcp/platforms/umc/src/recogscenario.cpp b/libs/unimrcp/platforms/umc/src/recogscenario.cpp index eb13a9a81d..658a46586d 100644 --- a/libs/unimrcp/platforms/umc/src/recogscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/recogscenario.cpp @@ -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 @@ -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; diff --git a/libs/unimrcp/platforms/umc/src/recogsession.cpp b/libs/unimrcp/platforms/umc/src/recogsession.cpp index c9a418d923..5779bf4418 100644 --- a/libs/unimrcp/platforms/umc/src/recogsession.cpp +++ b/libs/unimrcp/platforms/umc/src/recogsession.cpp @@ -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); diff --git a/libs/unimrcp/platforms/umc/src/recorderscenario.cpp b/libs/unimrcp/platforms/umc/src/recorderscenario.cpp index dd0ee2b1a9..6d303b848a 100644 --- a/libs/unimrcp/platforms/umc/src/recorderscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/recorderscenario.cpp @@ -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 diff --git a/libs/unimrcp/platforms/umc/src/recordersession.cpp b/libs/unimrcp/platforms/umc/src/recordersession.cpp index e10369eeb5..886e3248fb 100644 --- a/libs/unimrcp/platforms/umc/src/recordersession.cpp +++ b/libs/unimrcp/platforms/umc/src/recordersession.cpp @@ -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); diff --git a/libs/unimrcp/platforms/umc/src/setparamscenario.cpp b/libs/unimrcp/platforms/umc/src/setparamscenario.cpp index c2b62b1934..cbb203379e 100644 --- a/libs/unimrcp/platforms/umc/src/setparamscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/setparamscenario.cpp @@ -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" diff --git a/libs/unimrcp/platforms/umc/src/setparamsession.cpp b/libs/unimrcp/platforms/umc/src/setparamsession.cpp index cc60a020a7..c1fabd3e77 100644 --- a/libs/unimrcp/platforms/umc/src/setparamsession.cpp +++ b/libs/unimrcp/platforms/umc/src/setparamsession.cpp @@ -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 }; diff --git a/libs/unimrcp/platforms/umc/src/synthscenario.cpp b/libs/unimrcp/platforms/umc/src/synthscenario.cpp index b104ef20a6..de1718ce47 100644 --- a/libs/unimrcp/platforms/umc/src/synthscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/synthscenario.cpp @@ -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 diff --git a/libs/unimrcp/platforms/umc/src/synthsession.cpp b/libs/unimrcp/platforms/umc/src/synthsession.cpp index 003d2f6b62..07adaf6cbb 100644 --- a/libs/unimrcp/platforms/umc/src/synthsession.cpp +++ b/libs/unimrcp/platforms/umc/src/synthsession.cpp @@ -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; } diff --git a/libs/unimrcp/platforms/umc/src/umcconsole.cpp b/libs/unimrcp/platforms/umc/src/umcconsole.cpp index feff85c6b2..3165854082 100644 --- a/libs/unimrcp/platforms/umc/src/umcconsole.cpp +++ b/libs/unimrcp/platforms/umc/src/umcconsole.cpp @@ -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 @@ -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; diff --git a/libs/unimrcp/platforms/umc/src/umcframework.cpp b/libs/unimrcp/platforms/umc/src/umcframework.cpp index 9c06064919..50ac00c415 100644 --- a/libs/unimrcp/platforms/umc/src/umcframework.cpp +++ b/libs/unimrcp/platforms/umc/src/umcframework.cpp @@ -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); diff --git a/libs/unimrcp/platforms/umc/src/umcscenario.cpp b/libs/unimrcp/platforms/umc/src/umcscenario.cpp index f48bea74c9..085aa755fb 100644 --- a/libs/unimrcp/platforms/umc/src/umcscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/umcscenario.cpp @@ -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 @@ -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) diff --git a/libs/unimrcp/platforms/umc/src/umcsession.cpp b/libs/unimrcp/platforms/umc/src/umcsession.cpp index d619893cac..29618e0925 100644 --- a/libs/unimrcp/platforms/umc/src/umcsession.cpp +++ b/libs/unimrcp/platforms/umc/src/umcsession.cpp @@ -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" diff --git a/libs/unimrcp/platforms/umc/src/verifierscenario.cpp b/libs/unimrcp/platforms/umc/src/verifierscenario.cpp index 23ee362803..e11d3f6e93 100644 --- a/libs/unimrcp/platforms/umc/src/verifierscenario.cpp +++ b/libs/unimrcp/platforms/umc/src/verifierscenario.cpp @@ -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 diff --git a/libs/unimrcp/platforms/umc/src/verifiersession.cpp b/libs/unimrcp/platforms/umc/src/verifiersession.cpp index c44530e006..c9da9f4465 100644 --- a/libs/unimrcp/platforms/umc/src/verifiersession.cpp +++ b/libs/unimrcp/platforms/umc/src/verifiersession.cpp @@ -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) diff --git a/libs/unimrcp/platforms/umc/umc.rc b/libs/unimrcp/platforms/umc/umc.rc index 511efb81b6..98a3cf9209 100644 --- a/libs/unimrcp/platforms/umc/umc.rc +++ b/libs/unimrcp/platforms/umc/umc.rc @@ -1,39 +1,39 @@ -#include "uni_version.h" - -1 VERSIONINFO - FILEVERSION UNI_VERSION_STRING_CSV,0 - PRODUCTVERSION UNI_VERSION_STRING_CSV,0 - FILEFLAGSMASK 0x3fL -#if defined(_DEBUG) - FILEFLAGS 0x01L -#else - FILEFLAGS 0x00L -#endif -#if defined(WINNT) || defined(WIN64) - FILEOS 0x40004L -#else - FILEOS 0x4L -#endif - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", UNI_LICENSE "\0" - VALUE "CompanyName", "UniMRCP\0" - VALUE "FileDescription", "UniMRCP Client Application\0" - VALUE "FileVersion", UNI_VERSION_STRING "\0" - VALUE "InternalName", "umc" "\0" - VALUE "LegalCopyright", UNI_COPYRIGHT "\0" - VALUE "OriginalFilename", "umc.exe" "\0" - VALUE "ProductName", "UniMRCP Project\0" - VALUE "ProductVersion", UNI_VERSION_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END +#include "uni_version.h" + +1 VERSIONINFO + FILEVERSION UNI_VERSION_STRING_CSV,0 + PRODUCTVERSION UNI_VERSION_STRING_CSV,0 + FILEFLAGSMASK 0x3fL +#if defined(_DEBUG) + FILEFLAGS 0x01L +#else + FILEFLAGS 0x00L +#endif +#if defined(WINNT) || defined(WIN64) + FILEOS 0x40004L +#else + FILEOS 0x4L +#endif + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", UNI_LICENSE "\0" + VALUE "CompanyName", "UniMRCP\0" + VALUE "FileDescription", "UniMRCP Client Application\0" + VALUE "FileVersion", UNI_VERSION_STRING "\0" + VALUE "InternalName", "umc" "\0" + VALUE "LegalCopyright", UNI_COPYRIGHT "\0" + VALUE "OriginalFilename", "umc.exe" "\0" + VALUE "ProductName", "UniMRCP Project\0" + VALUE "ProductVersion", UNI_VERSION_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/libs/unimrcp/platforms/umc/umc.vcxproj b/libs/unimrcp/platforms/umc/umc.vcxproj new file mode 100644 index 0000000000..4727671ea5 --- /dev/null +++ b/libs/unimrcp/platforms/umc/umc.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894} + umc + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + + + + + include;%(AdditionalIncludeDirectories) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + + + + + {ee157390-1e85-416c-946e-620e32c9ad33} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/umc/umc.vcxproj.filters b/libs/unimrcp/platforms/umc/umc.vcxproj.filters new file mode 100644 index 0000000000..8fbefd40bc --- /dev/null +++ b/libs/unimrcp/platforms/umc/umc.vcxproj.filters @@ -0,0 +1,119 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/unimrcp-client/Makefile.am b/libs/unimrcp/platforms/unimrcp-client/Makefile.am index c0073b850b..f7310d2765 100644 --- a/libs/unimrcp/platforms/unimrcp-client/Makefile.am +++ b/libs/unimrcp/platforms/unimrcp-client/Makefile.am @@ -1,20 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(unimrcp_srcdir)/platforms/unimrcp-client/include \ - -I$(top_srcdir)/platforms/libunimrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-client/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = -I$(top_srcdir)/platforms/unimrcp-client/include \ + $(UNIMRCP_CLIENTAPP_INCLUDES) bin_PROGRAMS = unimrcpclient + unimrcpclient_SOURCES = src/main.c \ src/demo_framework.c \ src/demo_synth_application.c \ @@ -22,8 +10,7 @@ unimrcpclient_SOURCES = src/main.c \ src/demo_bypass_application.c \ src/demo_discover_application.c \ src/demo_util.c -unimrcpclient_LDADD = $(top_builddir)/platforms/libunimrcp-client/libunimrcpclient.la +unimrcpclient_LDADD = $(UNIMRCP_CLIENTAPP_LIBS) +unimrcpclient_LDFLAGS = $(UNIMRCP_CLIENTAPP_OPTS) -if ISMAC -unimrcpclient_LDFLAGS = -framework CoreFoundation -framework SystemConfiguration -endif +include $(top_srcdir)/build/rules/uniclientapp.am diff --git a/libs/unimrcp/platforms/unimrcp-client/include/demo_application.h b/libs/unimrcp/platforms/unimrcp-client/include/demo_application.h index 305858b642..a1f3899a7c 100644 --- a/libs/unimrcp/platforms/unimrcp-client/include/demo_application.h +++ b/libs/unimrcp/platforms/unimrcp-client/include/demo_application.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: demo_application.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: demo_application.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef DEMO_APPLICATION_H diff --git a/libs/unimrcp/platforms/unimrcp-client/include/demo_framework.h b/libs/unimrcp/platforms/unimrcp-client/include/demo_framework.h index ef173ef7de..e7b7ccdeaa 100644 --- a/libs/unimrcp/platforms/unimrcp-client/include/demo_framework.h +++ b/libs/unimrcp/platforms/unimrcp-client/include/demo_framework.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: demo_framework.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: demo_framework.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef DEMO_FRAMEWORK_H diff --git a/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h b/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h index 82b1d5ada5..7e686e275a 100644 --- a/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h +++ b/libs/unimrcp/platforms/unimrcp-client/include/demo_util.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: demo_util.h 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: demo_util.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #ifndef DEMO_UTIL_H @@ -36,9 +36,6 @@ mrcp_message_t* demo_define_grammar_message_create(mrcp_session_t *session, mrcp /** Create demo MRCP message (RECOGNIZE request) */ mrcp_message_t* demo_recognize_message_create(mrcp_session_t *session, mrcp_channel_t *channel, const apt_dir_layout_t *dir_layout); -/** Parse NLSML result */ -apt_bool_t demo_nlsml_result_parse(mrcp_message_t *message); - /** Create demo RTP termination descriptor */ mpf_rtp_termination_descriptor_t* demo_rtp_descriptor_create(apr_pool_t *pool); diff --git a/libs/unimrcp/platforms/unimrcp-client/src/demo_bypass_application.c b/libs/unimrcp/platforms/unimrcp-client/src/demo_bypass_application.c index 5780a87ae5..1eef85788c 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/demo_bypass_application.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/demo_bypass_application.c @@ -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 */ }; diff --git a/libs/unimrcp/platforms/unimrcp-client/src/demo_discover_application.c b/libs/unimrcp/platforms/unimrcp-client/src/demo_discover_application.c index 652fc72a07..0218f5637d 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/demo_discover_application.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/demo_discover_application.c @@ -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 $ */ /* diff --git a/libs/unimrcp/platforms/unimrcp-client/src/demo_framework.c b/libs/unimrcp/platforms/unimrcp-client/src/demo_framework.c index 69ac8b1a60..e3738a2211 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/demo_framework.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/demo_framework.c @@ -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 @@ -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); diff --git a/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c b/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c index a4b4845741..a87ca874c9 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c @@ -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; } diff --git a/libs/unimrcp/platforms/unimrcp-client/src/demo_synth_application.c b/libs/unimrcp/platforms/unimrcp-client/src/demo_synth_application.c index d010bb3883..e99d5a8490 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/demo_synth_application.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/demo_synth_application.c @@ -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); + } } } } diff --git a/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c b/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c index ebbc0a5c67..fa59112578 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c @@ -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) { diff --git a/libs/unimrcp/platforms/unimrcp-client/src/main.c b/libs/unimrcp/platforms/unimrcp-client/src/main.c index 5da982b533..702c254b8b 100644 --- a/libs/unimrcp/platforms/unimrcp-client/src/main.c +++ b/libs/unimrcp/platforms/unimrcp-client/src/main.c @@ -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 #include #include #include #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 */ diff --git a/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.2008.vcproj b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.2008.vcproj deleted file mode 100644 index 46cd13ccaa..0000000000 --- a/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.2008.vcproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.rc b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.rc index b7d34091c4..6bfb85f311 100644 --- a/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.rc +++ b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.rc @@ -1,39 +1,39 @@ -#include "uni_version.h" - -1 VERSIONINFO - FILEVERSION UNI_VERSION_STRING_CSV,0 - PRODUCTVERSION UNI_VERSION_STRING_CSV,0 - FILEFLAGSMASK 0x3fL -#if defined(_DEBUG) - FILEFLAGS 0x01L -#else - FILEFLAGS 0x00L -#endif -#if defined(WINNT) || defined(WIN64) - FILEOS 0x40004L -#else - FILEOS 0x4L -#endif - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", UNI_LICENSE "\0" - VALUE "CompanyName", "UniMRCP\0" - VALUE "FileDescription", "UniMRCP Client Application\0" - VALUE "FileVersion", UNI_VERSION_STRING "\0" - VALUE "InternalName", "unimrcpclient" "\0" - VALUE "LegalCopyright", UNI_COPYRIGHT "\0" - VALUE "OriginalFilename", "unimrcpclient.exe" "\0" - VALUE "ProductName", "UniMRCP Project\0" - VALUE "ProductVersion", UNI_VERSION_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END +#include "uni_version.h" + +1 VERSIONINFO + FILEVERSION UNI_VERSION_STRING_CSV,0 + PRODUCTVERSION UNI_VERSION_STRING_CSV,0 + FILEFLAGSMASK 0x3fL +#if defined(_DEBUG) + FILEFLAGS 0x01L +#else + FILEFLAGS 0x00L +#endif +#if defined(WINNT) || defined(WIN64) + FILEOS 0x40004L +#else + FILEOS 0x4L +#endif + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", UNI_LICENSE "\0" + VALUE "CompanyName", "UniMRCP\0" + VALUE "FileDescription", "UniMRCP Client Application\0" + VALUE "FileVersion", UNI_VERSION_STRING "\0" + VALUE "InternalName", "unimrcpclient" "\0" + VALUE "LegalCopyright", UNI_COPYRIGHT "\0" + VALUE "OriginalFilename", "unimrcpclient.exe" "\0" + VALUE "ProductName", "UniMRCP Project\0" + VALUE "ProductVersion", UNI_VERSION_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj new file mode 100644 index 0000000000..e060a41cee --- /dev/null +++ b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {57FAF32E-49FD-491F-895D-132D0D5EFE0A} + unimrcpclient + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + + + + + include;%(AdditionalIncludeDirectories) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + $(UniMRCPClientLibs);%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + + + + + + + + + + + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + + + + + {ee157390-1e85-416c-946e-620e32c9ad33} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj.filters b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj.filters similarity index 52% rename from libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj.filters rename to libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj.filters index 452f77e19d..83f0ded84c 100644 --- a/libs/unimrcp/libs/mrcpv2-transport/mrcpv2transport.2010.vcxproj.filters +++ b/libs/unimrcp/platforms/unimrcp-client/unimrcpclient.vcxproj.filters @@ -1,44 +1,50 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {a92d3b8c-d54d-416c-b458-dc57ac24d2e9} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - include - - - include - - - - - src - - - src - - - src - - - src - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + + + include + + + include + + + include + + + + + \ No newline at end of file diff --git a/libs/unimrcp/platforms/unimrcp-server/Makefile.am b/libs/unimrcp/platforms/unimrcp-server/Makefile.am index b3d5218052..3e8b50823a 100644 --- a/libs/unimrcp/platforms/unimrcp-server/Makefile.am +++ b/libs/unimrcp/platforms/unimrcp-server/Makefile.am @@ -1,23 +1,9 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/platforms/libunimrcp-server/include \ - -I$(top_srcdir)/libs/mrcp-server/include \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp-signaling/include \ - -I$(top_srcdir)/libs/mrcpv2-transport/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = -I$(top_srcdir)/platforms/unimrcp-server/include \ + $(UNIMRCP_SERVERAPP_INCLUDES) bin_PROGRAMS = unimrcpserver unimrcpserver_SOURCES = src/main.c src/uni_cmdline.c src/uni_daemon.c -unimrcpserver_LDADD = $(top_builddir)/platforms/libunimrcp-server/libunimrcpserver.la +unimrcpserver_LDADD = $(UNIMRCP_SERVERAPP_LIBS) +unimrcpserver_LDFLAGS = $(UNIMRCP_SERVERAPP_OPTS) -if ISMAC -unimrcpserver_LDFLAGS = -framework CoreFoundation -framework SystemConfiguration -endif +include $(top_srcdir)/build/rules/uniserverapp.am diff --git a/libs/unimrcp/platforms/unimrcp-server/src/main.c b/libs/unimrcp/platforms/unimrcp-server/src/main.c index 3d2c75e78b..a295a44934 100644 --- a/libs/unimrcp/platforms/unimrcp-server/src/main.c +++ b/libs/unimrcp/platforms/unimrcp-server/src/main.c @@ -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.c 1785 2010-09-22 06:14:29Z achaloyan $ + * $Id: main.c 2204 2014-10-31 01:01:42Z achaloyan@gmail.com $ */ #include @@ -22,16 +22,21 @@ #include "apt_pool.h" #include "apt_dir_layout.h" #include "apt_log.h" +#include "uni_version.h" typedef struct { const char *root_dir_path; + const char *dir_layout_conf; apt_bool_t foreground; const char *log_priority; const char *log_output; +#ifdef WIN32 + const char *svcname; +#endif } server_options_t; #ifdef WIN32 -apt_bool_t uni_service_run(apt_dir_layout_t *dir_layout, apr_pool_t *pool); +apt_bool_t uni_service_run(const char *name, apt_dir_layout_t *dir_layout, apr_pool_t *pool); #else apt_bool_t uni_daemon_run(apt_dir_layout_t *dir_layout, apr_pool_t *pool); #endif @@ -42,6 +47,10 @@ apt_bool_t uni_cmdline_run(apt_dir_layout_t *dir_layout, apr_pool_t *pool); static void usage() { printf( + "\n" + " * "UNI_COPYRIGHT"\n" + " *\n" + UNI_LICENSE"\n" "\n" "Usage:\n" "\n" @@ -49,7 +58,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" @@ -58,12 +70,16 @@ static void usage() " (0-none, 1-console only, 2-file only, 3-both)\n" "\n" #ifdef WIN32 - " -s [--service] : Run as the Windows service.\n" + " -s [--service] : Run as a Windows service.\n" + "\n" + " -n [--name] svcname : Set the service name (default: unimrcp)\n" "\n" #else - " -d [--daemon] : Run as the daemon.\n" + " -d [--daemon] : Run as a daemon.\n" "\n" #endif + " -v [--version] : Show the version.\n" + "\n" " -h [--help] : Show the help.\n" "\n"); } @@ -77,16 +93,19 @@ static apt_bool_t options_load(server_options_t *options, int argc, const char * 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 */ + { "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 */ #ifdef WIN32 - { "service", 's', FALSE, "run as service" }, /* -s or --service */ + { "service", 's', FALSE, "run as service" }, /* -s or --service */ + { "name", 'n', TRUE, "service name" }, /* -n or --name arg */ #else - { "daemon", 'd', FALSE, "start as daemon" }, /* -d or --daemon */ + { "daemon", 'd', FALSE, "start as daemon" }, /* -d or --daemon */ #endif - { "help", 'h', FALSE, "show help" }, /* -h or --help */ - { NULL, 0, 0, NULL }, /* end */ + { "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); @@ -94,11 +113,24 @@ static apt_bool_t options_load(server_options_t *options, int argc, const char * return FALSE; } + /* reset the options */ + options->root_dir_path = NULL; + options->dir_layout_conf = NULL; + options->foreground = TRUE; + options->log_priority = NULL; + options->log_output = NULL; +#ifdef WIN32 + options->svcname = NULL; +#endif + 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; @@ -109,11 +141,17 @@ static apt_bool_t options_load(server_options_t *options, int argc, const char * case 's': options->foreground = FALSE; break; + case 'n': + options->svcname = optarg; + break; #else case 'd': options->foreground = FALSE; break; #endif + case 'v': + printf(UNI_VERSION_STRING); + return FALSE; case 'h': usage(); return FALSE; @@ -130,10 +168,10 @@ static apt_bool_t options_load(server_options_t *options, int argc, const char * int main(int argc, const char * const *argv) { - apr_pool_t *pool = NULL; + apr_pool_t *pool; server_options_t options; - apt_dir_layout_t *dir_layout; const char *log_conf_path; + apt_dir_layout_t *dir_layout = NULL; /* APR global initialization */ if(apr_initialize() != APR_SUCCESS) { @@ -148,12 +186,6 @@ int main(int argc, const char * const *argv) return 0; } - /* set the default options */ - options.root_dir_path = "../"; - options.foreground = TRUE; - options.log_priority = NULL; - options.log_output = NULL; - /* load options */ if(options_load(&options,argc,argv,pool) != TRUE) { apr_pool_destroy(pool); @@ -161,9 +193,24 @@ 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); /* create and load singleton logger */ @@ -180,7 +227,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,"unimrcpserver",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,TRUE,pool); + const char *log_dir_path = apt_dir_layout_path_get(dir_layout,APT_LAYOUT_LOG_DIR); + apt_log_file_open(log_dir_path,"unimrcpserver",MAX_LOG_FILE_SIZE,MAX_LOG_FILE_COUNT,TRUE,pool); } if(options.foreground == TRUE) { @@ -190,7 +238,7 @@ int main(int argc, const char * const *argv) #ifdef WIN32 else { /* run as windows service */ - uni_service_run(dir_layout,pool); + uni_service_run(options.svcname,dir_layout,pool); } #else else { diff --git a/libs/unimrcp/platforms/unimrcp-server/src/uni_cmdline.c b/libs/unimrcp/platforms/unimrcp-server/src/uni_cmdline.c index 36db7f6412..e79132bb49 100644 --- a/libs/unimrcp/platforms/unimrcp-server/src/uni_cmdline.c +++ b/libs/unimrcp/platforms/unimrcp-server/src/uni_cmdline.c @@ -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: uni_cmdline.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: uni_cmdline.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -52,7 +52,7 @@ apt_bool_t uni_cmdline_run(apt_dir_layout_t *dir_layout, apr_pool_t *pool) { apt_bool_t running = TRUE; char cmdline[1024]; - int i; + apr_size_t i; mrcp_server_t *server; /* start server */ diff --git a/libs/unimrcp/platforms/unimrcp-server/src/uni_daemon.c b/libs/unimrcp/platforms/unimrcp-server/src/uni_daemon.c index 76c1b00a87..969f14dd60 100644 --- a/libs/unimrcp/platforms/unimrcp-server/src/uni_daemon.c +++ b/libs/unimrcp/platforms/unimrcp-server/src/uni_daemon.c @@ -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: uni_daemon.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: uni_daemon.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/platforms/unimrcp-server/src/uni_service.c b/libs/unimrcp/platforms/unimrcp-server/src/uni_service.c index b179b90e7b..31b70c0c39 100644 --- a/libs/unimrcp/platforms/unimrcp-server/src/uni_service.c +++ b/libs/unimrcp/platforms/unimrcp-server/src/uni_service.c @@ -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: uni_service.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: uni_service.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include @@ -28,11 +28,25 @@ static SERVICE_STATUS win_service_status; static mrcp_server_t *server = NULL; static apt_dir_layout_t *service_dir_layout = NULL; +static const char *svcname = NULL; + +/** Display error message with Windows error code and description */ +static void winerror(const char *file, int line, const char *msg) +{ + char buf[128]; + DWORD err = GetLastError(); + int ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + buf, sizeof(buf), NULL); + apt_log(file, line, APT_PRIO_WARNING, "%s: %lu %.*s\n", msg, err, ret, buf); +} /** SCM state change handler */ static void WINAPI win_service_handler(DWORD control) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Service Handler %d",control); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Service Handler 0x%02lx",control); switch (control) { case SERVICE_CONTROL_INTERROGATE: @@ -42,7 +56,7 @@ static void WINAPI win_service_handler(DWORD control) if(server) { win_service_status.dwCurrentState = SERVICE_STOP_PENDING; if(!SetServiceStatus(win_service_status_handle, &win_service_status)) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Set Service Status %d",GetLastError()); + winerror(APT_LOG_MARK, "Failed to Set Service Status"); } /* shutdown server */ @@ -55,7 +69,7 @@ static void WINAPI win_service_handler(DWORD control) } if(!SetServiceStatus(win_service_status_handle, &win_service_status)) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Set Service Status %d",GetLastError()); + winerror(APT_LOG_MARK, "Failed to Set Service Status"); } } @@ -69,15 +83,15 @@ static void WINAPI win_service_main(DWORD argc, LPTSTR *argv) win_service_status.dwCheckPoint = 0; win_service_status.dwWaitHint = 0; - win_service_status_handle = RegisterServiceCtrlHandler(WIN_SERVICE_NAME, win_service_handler); + win_service_status_handle = RegisterServiceCtrlHandler(svcname, win_service_handler); if(win_service_status_handle == (SERVICE_STATUS_HANDLE)0) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Register Service Control Handler %d",GetLastError()); + winerror(APT_LOG_MARK, "Failed to Register Service Control Handler"); return; } win_service_status.dwCurrentState = SERVICE_START_PENDING; if(!SetServiceStatus(win_service_status_handle, &win_service_status)) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Set Service Status %d",GetLastError()); + winerror(APT_LOG_MARK, "Failed to Set Service Status"); } /* start server */ @@ -85,22 +99,23 @@ static void WINAPI win_service_main(DWORD argc, LPTSTR *argv) win_service_status.dwCurrentState = server ? SERVICE_RUNNING : SERVICE_STOPPED; if(!SetServiceStatus(win_service_status_handle, &win_service_status)) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Set Service Status %d",GetLastError()); + winerror(APT_LOG_MARK, "Failed to Set Service Status"); } } /** Run SCM service */ -apt_bool_t uni_service_run(apt_dir_layout_t *dir_layout, apr_pool_t *pool) +apt_bool_t uni_service_run(const char *name, apt_dir_layout_t *dir_layout, apr_pool_t *pool) { - SERVICE_TABLE_ENTRY win_service_table[] = { - { WIN_SERVICE_NAME, win_service_main }, - { NULL, NULL } - }; + SERVICE_TABLE_ENTRY win_service_table[2]; + svcname = name ? name : WIN_SERVICE_NAME; + memset(&win_service_table, 0, sizeof(win_service_table)); + win_service_table->lpServiceName = (char *) svcname; + win_service_table->lpServiceProc = win_service_main; service_dir_layout = dir_layout; - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Run as Service"); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Run as Service %s",svcname); if(!StartServiceCtrlDispatcher(win_service_table)) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Connect to SCM %d",GetLastError()); + winerror(APT_LOG_MARK, "Failed to Connect to SCM"); } return TRUE; } diff --git a/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.2008.vcproj b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.2008.vcproj deleted file mode 100644 index 147b8dccde..0000000000 --- a/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.2008.vcproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.rc b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.rc index 7c562afc96..4f6c5dd891 100644 --- a/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.rc +++ b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.rc @@ -1,39 +1,39 @@ -#include "uni_version.h" - -1 VERSIONINFO - FILEVERSION UNI_VERSION_STRING_CSV,0 - PRODUCTVERSION UNI_VERSION_STRING_CSV,0 - FILEFLAGSMASK 0x3fL -#if defined(_DEBUG) - FILEFLAGS 0x01L -#else - FILEFLAGS 0x00L -#endif -#if defined(WINNT) || defined(WIN64) - FILEOS 0x40004L -#else - FILEOS 0x4L -#endif - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", UNI_LICENSE "\0" - VALUE "CompanyName", "UniMRCP\0" - VALUE "FileDescription", "UniMRCP Server Application\0" - VALUE "FileVersion", UNI_VERSION_STRING "\0" - VALUE "InternalName", "unimrcpserver" "\0" - VALUE "LegalCopyright", UNI_COPYRIGHT "\0" - VALUE "OriginalFilename", "unimrcpserver.exe" "\0" - VALUE "ProductName", "UniMRCP Project\0" - VALUE "ProductVersion", UNI_VERSION_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END +#include "uni_version.h" + +1 VERSIONINFO + FILEVERSION UNI_VERSION_STRING_CSV,0 + PRODUCTVERSION UNI_VERSION_STRING_CSV,0 + FILEFLAGSMASK 0x3fL +#if defined(_DEBUG) + FILEFLAGS 0x01L +#else + FILEFLAGS 0x00L +#endif +#if defined(WINNT) || defined(WIN64) + FILEOS 0x40004L +#else + FILEOS 0x4L +#endif + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", UNI_LICENSE "\0" + VALUE "CompanyName", "UniMRCP\0" + VALUE "FileDescription", "UniMRCP Server Application\0" + VALUE "FileVersion", UNI_VERSION_STRING "\0" + VALUE "InternalName", "unimrcpserver" "\0" + VALUE "LegalCopyright", UNI_COPYRIGHT "\0" + VALUE "OriginalFilename", "unimrcpserver.exe" "\0" + VALUE "ProductName", "UniMRCP Project\0" + VALUE "ProductVersion", UNI_VERSION_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj new file mode 100644 index 0000000000..e3e7594bbe --- /dev/null +++ b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {592CF22D-3F8F-4A77-A174-130D77B7623B} + unimrcpserver + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + $(UniMRCPServerLibs);%(AdditionalDependencies) + + + + + $(UniMRCPServerLibs);%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + ProgramDatabase + + + $(UniMRCPServerLibs);%(AdditionalDependencies) + + + + + X64 + + + $(UniMRCPServerLibs);%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + + + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + ..\..\build;%(AdditionalIncludeDirectories) + + + + + {c98af157-352e-4737-bd30-a24e2647f5ae} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj.filters b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj.filters similarity index 52% rename from libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj.filters rename to libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj.filters index a990550f29..6b335bf544 100644 --- a/libs/unimrcp/modules/mrcp-unirtsp/mrcpunirtsp.2012.vcxproj.filters +++ b/libs/unimrcp/platforms/unimrcp-server/unimrcpserver.vcxproj.filters @@ -1,35 +1,30 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {f87f8ada-12d1-412b-bd14-7e62df3f92a0} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - include - - - include - - - include - - - - - src - - - src - - - src - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + src + + + src + + + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/Makefile.am b/libs/unimrcp/plugins/Makefile.am index 9d8b7b5964..2300a4934a 100644 --- a/libs/unimrcp/plugins/Makefile.am +++ b/libs/unimrcp/plugins/Makefile.am @@ -17,11 +17,3 @@ endif if RECORDER_PLUGIN SUBDIRS += mrcp-recorder endif - -if POCKETSPHINX_PLUGIN -SUBDIRS += mrcp-pocketsphinx -endif - -if FLITE_PLUGIN -SUBDIRS += mrcp-flite -endif diff --git a/libs/unimrcp/plugins/demo-recog/Makefile.am b/libs/unimrcp/plugins/demo-recog/Makefile.am index dea736be69..51babdaaa3 100644 --- a/libs/unimrcp/plugins/demo-recog/Makefile.am +++ b/libs/unimrcp/plugins/demo-recog/Makefile.am @@ -1,16 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = $(UNIMRCP_PLUGIN_INCLUDES) plugin_LTLIBRARIES = demorecog.la demorecog_la_SOURCES = src/demo_recog_engine.c -demorecog_la_LDFLAGS = -module $(PLUGIN_LT_VERSION) +demorecog_la_LDFLAGS = $(UNIMRCP_PLUGIN_OPTS) + +include $(top_srcdir)/build/rules/uniplugin.am diff --git a/libs/unimrcp/plugins/demo-recog/demorecog.2008.vcproj b/libs/unimrcp/plugins/demo-recog/demorecog.2008.vcproj deleted file mode 100644 index ff23c031b4..0000000000 --- a/libs/unimrcp/plugins/demo-recog/demorecog.2008.vcproj +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2012.vcxproj b/libs/unimrcp/plugins/demo-recog/demorecog.vcxproj similarity index 57% rename from libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2012.vcxproj rename to libs/unimrcp/plugins/demo-recog/demorecog.vcxproj index 3127301c9d..9a7adfa8c5 100644 --- a/libs/unimrcp/libs/mrcp-signaling/mrcpsignaling.2012.vcxproj +++ b/libs/unimrcp/plugins/demo-recog/demorecog.vcxproj @@ -1,125 +1,123 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpsignaling - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} - mrcpsignaling - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B495B6D9-AF84-479D-B30A-313C16EF8BFD} + demorecog + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + + + include;%(AdditionalIncludeDirectories) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + + + + + + {843425be-9a9a-44f4-a4e3-4b57d6abd53c} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/demo-recog/demorecog.vcxproj.filters b/libs/unimrcp/plugins/demo-recog/demorecog.vcxproj.filters new file mode 100644 index 0000000000..af5b05f706 --- /dev/null +++ b/libs/unimrcp/plugins/demo-recog/demorecog.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4c5e54ad-7563-43a7-8b11-5067a45289e9} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/demo-recog/src/demo_recog_engine.c b/libs/unimrcp/plugins/demo-recog/src/demo_recog_engine.c index 95681c8c84..75954a45b2 100644 --- a/libs/unimrcp/plugins/demo-recog/src/demo_recog_engine.c +++ b/libs/unimrcp/plugins/demo-recog/src/demo_recog_engine.c @@ -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_engine.c 1706 2010-05-23 14:11:11Z achaloyan $ + * $Id: demo_recog_engine.c 2193 2014-10-08 03:44:33Z achaloyan@gmail.com $ */ /* @@ -80,7 +80,8 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = { NULL, demo_recog_stream_open, demo_recog_stream_close, - demo_recog_stream_write + demo_recog_stream_write, + NULL }; /** Declaration of demo recognizer engine */ @@ -259,6 +260,14 @@ static apt_bool_t demo_recog_channel_recognize(mrcp_engine_channel_t *channel, m /* process RECOGNIZE request */ mrcp_recog_header_t *recog_header; demo_recog_channel_t *recog_channel = channel->method_obj; + const mpf_codec_descriptor_t *descriptor = mrcp_engine_sink_stream_codec_get(channel); + + if(!descriptor) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Codec Descriptor "APT_SIDRES_FMT, MRCP_MESSAGE_SIDRES(request)); + response->start_line.status_code = MRCP_STATUS_CODE_METHOD_FAILED; + return FALSE; + } + recog_channel->timers_started = TRUE; /* get recognizer header */ @@ -277,13 +286,16 @@ static apt_bool_t demo_recog_channel_recognize(mrcp_engine_channel_t *channel, m if(!recog_channel->audio_out) { const apt_dir_layout_t *dir_layout = channel->engine->dir_layout; - const mpf_codec_descriptor_t *descriptor = mrcp_engine_sink_stream_codec_get(channel); char *file_name = apr_psprintf(channel->pool,"utter-%dkHz-%s.pcm", - descriptor ? descriptor->sampling_rate/1000 : 8, - request->channel_id.session_id.buf); - char *file_path = apt_datadir_filepath_get(dir_layout,file_name,channel->pool); + descriptor->sampling_rate/1000, + request->channel_id.session_id.buf); + char *file_path = apt_vardir_filepath_get(dir_layout,file_name,channel->pool); if(file_path) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Utterance Output File [%s] for Writing",file_path); recog_channel->audio_out = fopen(file_path,"wb"); + if(!recog_channel->audio_out) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Utterance Output File [%s] for Writing",file_path); + } } } diff --git a/libs/unimrcp/plugins/demo-synth/Makefile.am b/libs/unimrcp/plugins/demo-synth/Makefile.am index 72f251d2a8..4b62aef593 100644 --- a/libs/unimrcp/plugins/demo-synth/Makefile.am +++ b/libs/unimrcp/plugins/demo-synth/Makefile.am @@ -1,16 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = $(UNIMRCP_PLUGIN_INCLUDES) plugin_LTLIBRARIES = demosynth.la demosynth_la_SOURCES = src/demo_synth_engine.c -demosynth_la_LDFLAGS = -module $(PLUGIN_LT_VERSION) +demosynth_la_LDFLAGS = $(UNIMRCP_PLUGIN_OPTS) + +include $(top_srcdir)/build/rules/uniplugin.am diff --git a/libs/unimrcp/plugins/demo-synth/demosynth.2008.vcproj b/libs/unimrcp/plugins/demo-synth/demosynth.2008.vcproj deleted file mode 100644 index 3c5897e6ee..0000000000 --- a/libs/unimrcp/plugins/demo-synth/demosynth.2008.vcproj +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/plugins/demo-synth/demosynth.vcxproj b/libs/unimrcp/plugins/demo-synth/demosynth.vcxproj new file mode 100644 index 0000000000..3afc81ed5a --- /dev/null +++ b/libs/unimrcp/plugins/demo-synth/demosynth.vcxproj @@ -0,0 +1,123 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {92BFA534-C419-4EB2-AAA3-510653F38F08} + demosynth + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + + + include;%(AdditionalIncludeDirectories) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + + + + + + {843425be-9a9a-44f4-a4e3-4b57d6abd53c} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/demo-synth/demosynth.vcxproj.filters b/libs/unimrcp/plugins/demo-synth/demosynth.vcxproj.filters new file mode 100644 index 0000000000..1c71d5467d --- /dev/null +++ b/libs/unimrcp/plugins/demo-synth/demosynth.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {c816d2c0-8f04-4474-ad43-cfac130a1a84} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/demo-synth/src/demo_synth_engine.c b/libs/unimrcp/plugins/demo-synth/src/demo_synth_engine.c index 9daa99f5e3..bc68c895fa 100644 --- a/libs/unimrcp/plugins/demo-synth/src/demo_synth_engine.c +++ b/libs/unimrcp/plugins/demo-synth/src/demo_synth_engine.c @@ -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_engine.c 1706 2010-05-23 14:11:11Z achaloyan $ + * $Id: demo_synth_engine.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ /* @@ -79,6 +79,7 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = { demo_synth_stream_read, NULL, NULL, + NULL, NULL }; @@ -102,7 +103,7 @@ struct demo_synth_channel_t { apr_size_t time_to_complete; /** Is paused */ apt_bool_t paused; - /** Speech source (used instead of actual synthesizing) */ + /** Speech source (used instead of actual synthesis) */ FILE *audio_file; }; @@ -262,11 +263,17 @@ static apt_bool_t demo_synth_channel_speak(mrcp_engine_channel_t *channel, mrcp_ { char *file_path = NULL; demo_synth_channel_t *synth_channel = channel->method_obj; + const mpf_codec_descriptor_t *descriptor = mrcp_engine_source_stream_codec_get(channel); + + if(!descriptor) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Codec Descriptor "APT_SIDRES_FMT, MRCP_MESSAGE_SIDRES(request)); + response->start_line.status_code = MRCP_STATUS_CODE_METHOD_FAILED; + return FALSE; + } + synth_channel->time_to_complete = 0; if(channel->engine) { - const mpf_codec_descriptor_t *descriptor = mrcp_engine_source_stream_codec_get(channel); - char *file_name = apr_psprintf(channel->pool,"demo-%dkHz.pcm", - descriptor ? descriptor->sampling_rate/1000 : 8); + char *file_name = apr_psprintf(channel->pool,"demo-%dkHz.pcm",descriptor->sampling_rate/1000); file_path = apt_datadir_filepath_get(channel->engine->dir_layout,file_name,channel->pool); } if(file_path) { @@ -289,7 +296,7 @@ static apt_bool_t demo_synth_channel_speak(mrcp_engine_channel_t *channel, mrcp_ } } } - + response->start_line.request_state = MRCP_REQUEST_STATE_INPROGRESS; /* send asynchronous response */ mrcp_engine_channel_message_send(channel,response); @@ -341,7 +348,7 @@ static apt_bool_t demo_synth_channel_set_params(mrcp_engine_channel_t *channel, /* check voice name header */ if(mrcp_resource_header_property_check(request,SYNTHESIZER_HEADER_VOICE_NAME) == TRUE) { apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Voice Name [%s]", - req_synth_header->voice_param.name); + req_synth_header->voice_param.name.buf); } } diff --git a/libs/unimrcp/plugins/demo-verifier/Makefile.am b/libs/unimrcp/plugins/demo-verifier/Makefile.am index 25266f604c..9da71c1024 100644 --- a/libs/unimrcp/plugins/demo-verifier/Makefile.am +++ b/libs/unimrcp/plugins/demo-verifier/Makefile.am @@ -1,16 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = $(UNIMRCP_PLUGIN_INCLUDES) plugin_LTLIBRARIES = demoverifier.la demoverifier_la_SOURCES = src/demo_verifier_engine.c -demoverifier_la_LDFLAGS = -module $(PLUGIN_LT_VERSION) +demoverifier_la_LDFLAGS = $(UNIMRCP_PLUGIN_OPTS) + +include $(top_srcdir)/build/rules/uniplugin.am diff --git a/libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj b/libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj new file mode 100644 index 0000000000..fe472259e4 --- /dev/null +++ b/libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj @@ -0,0 +1,123 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {F7563CAD-5C95-46E5-89B7-0953C6C6E746} + demoverifier + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + + + include;%(AdditionalIncludeDirectories) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + + + + + + {843425be-9a9a-44f4-a4e3-4b57d6abd53c} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj.filters b/libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj.filters new file mode 100644 index 0000000000..afd5da4d9f --- /dev/null +++ b/libs/unimrcp/plugins/demo-verifier/demoverifier.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {42255732-d637-4aef-ab75-104eb723ff72} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/demo-verifier/src/demo_verifier_engine.c b/libs/unimrcp/plugins/demo-verifier/src/demo_verifier_engine.c index 8918bedcbf..6e3d290d36 100644 --- a/libs/unimrcp/plugins/demo-verifier/src/demo_verifier_engine.c +++ b/libs/unimrcp/plugins/demo-verifier/src/demo_verifier_engine.c @@ -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_verifier_engine.c 1776 2010-08-27 16:36:38Z achaloyan $ + * $Id: demo_verifier_engine.c 2193 2014-10-08 03:44:33Z achaloyan@gmail.com $ */ /* @@ -80,7 +80,8 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = { NULL, demo_verifier_stream_open, demo_verifier_stream_close, - demo_verifier_stream_write + demo_verifier_stream_write, + NULL }; /** Declaration of demo verification engine */ @@ -261,6 +262,14 @@ static apt_bool_t demo_verifier_channel_verify(mrcp_engine_channel_t *channel, m /* process verify request */ mrcp_verifier_header_t *verifier_header; demo_verifier_channel_t *verifier_channel = channel->method_obj; + const mpf_codec_descriptor_t *descriptor = mrcp_engine_sink_stream_codec_get(channel); + + if(!descriptor) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Codec Descriptor "APT_SIDRES_FMT, MRCP_MESSAGE_SIDRES(request)); + response->start_line.status_code = MRCP_STATUS_CODE_METHOD_FAILED; + return FALSE; + } + verifier_channel->timers_started = TRUE; /* get verifier header */ @@ -279,13 +288,16 @@ static apt_bool_t demo_verifier_channel_verify(mrcp_engine_channel_t *channel, m if(!verifier_channel->audio_out) { const apt_dir_layout_t *dir_layout = channel->engine->dir_layout; - const mpf_codec_descriptor_t *descriptor = mrcp_engine_sink_stream_codec_get(channel); char *file_name = apr_psprintf(channel->pool,"voiceprint-%dkHz-%s.pcm", - descriptor ? descriptor->sampling_rate/1000 : 8, - request->channel_id.session_id.buf); - char *file_path = apt_datadir_filepath_get(dir_layout,file_name,channel->pool); + descriptor->sampling_rate/1000, + request->channel_id.session_id.buf); + char *file_path = apt_vardir_filepath_get(dir_layout,file_name,channel->pool); if(file_path) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Utterance Output File [%s] for Writing",file_path); verifier_channel->audio_out = fopen(file_path,"wb"); + if(!verifier_channel->audio_out) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Utterance Output File [%s] for Writing",file_path); + } } } diff --git a/libs/unimrcp/plugins/mrcp-flite/Makefile.am b/libs/unimrcp/plugins/mrcp-flite/Makefile.am deleted file mode 100644 index d2cec23779..0000000000 --- a/libs/unimrcp/plugins/mrcp-flite/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) \ - $(UNIMRCP_APU_INCLUDES) \ - $(UNIMRCP_FLITE_INCLUDES) - -plugin_LTLIBRARIES = mrcpflite.la - -mrcpflite_la_SOURCES = src/mrcp_flite.c src/flite_voices.c -mrcpflite_la_LDFLAGS = -module $(PLUGIN_LT_VERSION) -mrcpflite_la_LIBADD = $(UNIMRCP_FLITE_LIBS) -lm diff --git a/libs/unimrcp/plugins/mrcp-flite/include/flite_voices.h b/libs/unimrcp/plugins/mrcp-flite/include/flite_voices.h deleted file mode 100644 index 59ebaf8b4d..0000000000 --- a/libs/unimrcp/plugins/mrcp-flite/include/flite_voices.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2008-2010 Arsen Chaloyan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id: flite_voices.h 1474 2010-02-07 20:51:47Z achaloyan $ - */ - -#ifndef FLITE_VOICES_H -#define FLITE_VOICES_H - -/** - * @file flite_voices.h - * @brief Flite Voices - */ - -#include -#include -#include "mrcp_message.h" - -APT_BEGIN_EXTERN_C - - -/** Opaque Flite voice declaration */ -typedef struct flite_voices_t flite_voices_t; - -/** Load Flite voices */ -flite_voices_t* flite_voices_load(apr_pool_t *pool); -/** Unload Flite voices */ -void flite_voices_unload(flite_voices_t *voices); - -/** Get best matched voice */ -cst_voice* flite_voices_best_match_get(flite_voices_t *voices, mrcp_message_t *message); - -APT_END_EXTERN_C - -#endif /* FLITE_VOICES_H */ diff --git a/libs/unimrcp/plugins/mrcp-flite/mrcpflite.2008.vcproj b/libs/unimrcp/plugins/mrcp-flite/mrcpflite.2008.vcproj deleted file mode 100644 index 9767ed6e40..0000000000 --- a/libs/unimrcp/plugins/mrcp-flite/mrcpflite.2008.vcproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/plugins/mrcp-flite/mrcpflite.vcproj b/libs/unimrcp/plugins/mrcp-flite/mrcpflite.vcproj deleted file mode 100644 index 892384ae4f..0000000000 --- a/libs/unimrcp/plugins/mrcp-flite/mrcpflite.vcproj +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/plugins/mrcp-flite/src/flite_voices.c b/libs/unimrcp/plugins/mrcp-flite/src/flite_voices.c deleted file mode 100644 index d3bfe293ae..0000000000 --- a/libs/unimrcp/plugins/mrcp-flite/src/flite_voices.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2008-2010 Arsen Chaloyan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id: flite_voices.c 1474 2010-02-07 20:51:47Z achaloyan $ - */ - -#include "flite_voices.h" -#include "mrcp_synth_header.h" - -typedef struct flite_voice_t flite_voice_t; - -/** Declaration of flite voice */ -struct flite_voice_t { - const char *name; - cst_voice *self; - cst_voice* (*register_voice)(void); - void (*unregister_voice)(cst_voice *); -}; - -struct flite_voices_t { - apr_hash_t *table; - apr_pool_t *pool; -}; - - -/* declarations for flite voices */ -cst_voice *register_cmu_us_awb(void); -cst_voice *register_cmu_us_kal(void); -cst_voice *register_cmu_us_rms(void); -cst_voice *register_cmu_us_slt(void); -void unregister_cmu_us_awb(cst_voice * v); -void unregister_cmu_us_kal(cst_voice * v); -void unregister_cmu_us_rms(cst_voice * v); -void unregister_cmu_us_slt(cst_voice * v); - - -static apt_bool_t flite_voices_init(flite_voices_t *voices, apr_pool_t *pool) -{ - flite_voice_t *voice; - - voice = apr_palloc(pool,sizeof(flite_voice_t)); - voice->name = "awb"; - voice->self = NULL; - voice->register_voice = register_cmu_us_awb; - voice->unregister_voice = unregister_cmu_us_awb; - apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice); - - voice = apr_palloc(pool,sizeof(flite_voice_t)); - voice->name = "kal"; - voice->self = NULL; - voice->register_voice = register_cmu_us_kal; - voice->unregister_voice = unregister_cmu_us_kal; - apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice); - - voice = apr_palloc(pool,sizeof(flite_voice_t)); - voice->name = "rms"; - voice->self = NULL; - voice->register_voice = register_cmu_us_rms; - voice->unregister_voice = unregister_cmu_us_rms; - apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice); - - voice = apr_palloc(pool,sizeof(flite_voice_t)); - voice->name = "slt"; - voice->self = NULL; - voice->register_voice = register_cmu_us_slt; - voice->unregister_voice = unregister_cmu_us_slt; - apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice); - - return TRUE; -} - - -flite_voices_t* flite_voices_load(apr_pool_t *pool) -{ - flite_voice_t *voice; - apr_hash_index_t *it; - void *val; - - flite_voices_t *voices = apr_palloc(pool,sizeof(flite_voices_t)); - voices->pool = pool; - voices->table = apr_hash_make(pool); - - /* init voices */ - flite_voices_init(voices,pool); - - /* register voices */ - it = apr_hash_first(pool,voices->table); - /* walk through the voices and register them */ - for(; it; it = apr_hash_next(it)) { - apr_hash_this(it,NULL,NULL,&val); - voice = val; - if(voice) { - voice->self = voice->register_voice(); - } - } - - return voices; -} - -void flite_voices_unload(flite_voices_t *voices) -{ - flite_voice_t *voice; - apr_hash_index_t *it; - void *val; - - /* unregister voices */ - it = apr_hash_first(voices->pool,voices->table); - /* walk through the voices and register them */ - for(; it; it = apr_hash_next(it)) { - apr_hash_this(it,NULL,NULL,&val); - voice = val; - if(voice && voice->self) { - voice->unregister_voice(voice->self); - } - } -} - -cst_voice* flite_voices_best_match_get(flite_voices_t *voices, mrcp_message_t *message) -{ - cst_voice *voice = NULL; - const char *voice_name = NULL; - mrcp_synth_header_t *synth_header = mrcp_resource_header_get(message); - if(synth_header) { - if(mrcp_resource_header_property_check(message,SYNTHESIZER_HEADER_VOICE_NAME) == TRUE) { - voice_name = synth_header->voice_param.name.buf; - } - } - - if(voice_name) { - /* get voice by name */ - flite_voice_t *flite_voice; - flite_voice = apr_hash_get(voices->table,voice_name,APR_HASH_KEY_STRING); - if(flite_voice) { - voice = flite_voice->self; - } - } - - if(!voice) { - /* still no voice found, get the default one */ - flite_voice_t *flite_voice = NULL; - void *val; - apr_hash_index_t *it = apr_hash_first(voices->pool,voices->table); - apr_hash_this(it,NULL,NULL,&val); - if(val) { - flite_voice = val; - voice = flite_voice->self; - } - } - return voice; -} diff --git a/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c b/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c deleted file mode 100644 index b3b3f80130..0000000000 --- a/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Copyright 2008-2010 Arsen Chaloyan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id: mrcp_flite.c 1678 2010-05-01 18:54:07Z achaloyan $ - */ - -/* - * Mandatory rules concerning plugin implementation. - * 1. Each plugin MUST implement a plugin/engine creator function - * with the exact signature and name (the main entry point) - * MRCP_PLUGIN_DECLARE(mrcp_engine_t*) mrcp_plugin_create(apr_pool_t *pool) - * 2. Each plugin MUST declare its version number - * MRCP_PLUGIN_VERSION_DECLARE - * 3. One and only one response MUST be sent back to the received request. - * 4. Methods (callbacks) of the MRCP engine channel MUST not block. - * (asynchronous response can be sent from the context of other thread) - * 5. Methods (callbacks) of the MPF engine stream MUST not block. - */ - -#include "flite_voices.h" -#include "mrcp_synth_engine.h" -#include "mpf_buffer.h" -#include "apr_time.h" -#include "apt_consumer_task.h" -#include "apt_log.h" - -typedef struct flite_synth_engine_t flite_synth_engine_t; -typedef struct flite_synth_channel_t flite_synth_channel_t; - -/** Declaration of synthesizer engine methods */ -static apt_bool_t flite_synth_engine_destroy(mrcp_engine_t *engine); -static apt_bool_t flite_synth_engine_open(mrcp_engine_t *engine); -static apt_bool_t flite_synth_engine_close(mrcp_engine_t *engine); -static mrcp_engine_channel_t* flite_synth_engine_channel_create(mrcp_engine_t *engine, apr_pool_t *pool); - -static const struct mrcp_engine_method_vtable_t engine_vtable = { - flite_synth_engine_destroy, - flite_synth_engine_open, - flite_synth_engine_close, - flite_synth_engine_channel_create -}; - -/** Declaration of synthesizer channel methods */ -static apt_bool_t flite_synth_channel_destroy(mrcp_engine_channel_t *channel); -static apt_bool_t flite_synth_channel_open(mrcp_engine_channel_t *channel); -static apt_bool_t flite_synth_channel_close(mrcp_engine_channel_t *channel); -static apt_bool_t flite_synth_channel_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *request); - -/** flite channel methods for processing MRCP channel request **/ -static apt_bool_t flite_synth_channel_speak(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response); -static apt_bool_t flite_synth_channel_stop(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response); -static apt_bool_t flite_synth_channel_pause(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response); -static apt_bool_t flite_synth_channel_resume(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response); - -static const struct mrcp_engine_channel_method_vtable_t channel_vtable = { - flite_synth_channel_destroy, - flite_synth_channel_open, - flite_synth_channel_close, - flite_synth_channel_request_process -}; - -/** Declaration of synthesizer audio stream methods */ -static apt_bool_t flite_synth_stream_read(mpf_audio_stream_t *stream, mpf_frame_t *frame); - -static const mpf_audio_stream_vtable_t audio_stream_vtable = { - NULL, - NULL, - NULL, - flite_synth_stream_read, - NULL, - NULL, - NULL -}; - -/** Declaration of flite synthesizer engine */ -struct flite_synth_engine_t { - /** Table of flite voices */ - flite_voices_t *voices; - int iChannels; -}; - -/** Declaration of flite synthesizer channel */ -struct flite_synth_channel_t { - flite_synth_engine_t *flite_engine; /* Back pointer to engine */ - mrcp_engine_channel_t *channel; /* Engine channel base */ - mrcp_message_t *speak_request; /* Active (in-progress) speak request */ - mrcp_message_t *speak_response;/* Pending speak response */ - mrcp_message_t *stop_response; /* Pending stop response */ - apt_bool_t synthesizing; /* Is synthesizer task processing speak request */ - apt_bool_t paused; /* Is paused */ - mpf_buffer_t *audio_buffer; /* Audio buffer */ - int iId; /* Synth channel simultaneous reference count */ - apr_pool_t *pool; - apt_task_t *task; - apt_task_msg_pool_t *msg_pool; -}; - -/** Declaration of flite synthesizer task message */ -struct flite_speak_msg_t { - flite_synth_channel_t *channel; - mrcp_message_t *request; -}; - -typedef struct flite_speak_msg_t flite_speak_msg_t; - -/* we have a special task for the actual synthesis - - the task is created when a mrcp speak message is received */ -static apt_bool_t flite_speak(apt_task_t *task, apt_task_msg_t *msg); -static void flite_on_start(apt_task_t *task); -static void flite_on_terminate(apt_task_t *task); - -/** Declare this macro to set plugin version */ -MRCP_PLUGIN_VERSION_DECLARE - -/** Declare this macro to use log routine of the server where the plugin is loaded from */ -MRCP_PLUGIN_LOGGER_IMPLEMENT - -/** Create flite synthesizer engine */ -MRCP_PLUGIN_DECLARE(mrcp_engine_t*) mrcp_plugin_create(apr_pool_t *pool) -{ - /* create flite engine */ - flite_synth_engine_t *flite_engine = (flite_synth_engine_t *) apr_palloc(pool,sizeof(flite_synth_engine_t)); - flite_engine->iChannels = 0; - - /* create engine base */ - return mrcp_engine_create( - MRCP_SYNTHESIZER_RESOURCE, /* MRCP resource identifier */ - flite_engine, /* object to associate */ - &engine_vtable, /* virtual methods table of engine */ - pool); /* pool to allocate memory from */ -} - -/** Destroy synthesizer engine */ -static apt_bool_t flite_synth_engine_destroy(mrcp_engine_t *engine) -{ - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_engine_destroy"); - return TRUE; -} - -/** Open synthesizer engine */ -static apt_bool_t flite_synth_engine_open(mrcp_engine_t *engine) -{ - flite_synth_engine_t *flite_engine = (flite_synth_engine_t *) engine->obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_engine_open"); - - flite_init(); - - flite_engine->voices = flite_voices_load(engine->pool); - - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite init success"); - return mrcp_engine_open_respond(engine,TRUE); -} - -/** Close synthesizer engine */ -static apt_bool_t flite_synth_engine_close(mrcp_engine_t *engine) -{ - flite_synth_engine_t *flite_engine = (flite_synth_engine_t *) engine->obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_engine_close"); - - flite_voices_unload(flite_engine->voices); - - return mrcp_engine_close_respond(engine); -} - -static apt_bool_t flite_synth_task_create(flite_synth_channel_t *synth_channel) -{ - apt_task_msg_pool_t *msg_pool = apt_task_msg_pool_create_dynamic( sizeof(flite_speak_msg_t),synth_channel->pool); - apt_task_vtable_t *task_vtable = 0; - apt_consumer_task_t *consumer_task = 0; - - /* create task/thread to run flite synthesizer in */ - consumer_task = apt_consumer_task_create(synth_channel, msg_pool, synth_channel->pool); - if(!consumer_task) { - apt_log(APT_LOG_MARK,APT_PRIO_ERROR, "flite_synth_channel_speak failed to create flite speak task - channel:%d", synth_channel->iId); - return FALSE; - } - - task_vtable = apt_consumer_task_vtable_get(consumer_task); - if(task_vtable) { - task_vtable->process_msg = flite_speak; - task_vtable->on_pre_run = flite_on_start; - task_vtable->on_post_run = flite_on_terminate; - } - synth_channel->msg_pool = msg_pool; - synth_channel->task = apt_consumer_task_base_get(consumer_task); - if(synth_channel->task) { - apt_task_name_set(synth_channel->task,"Flite Task"); - } - return TRUE; -} - -/** Create flite synthesizer channel derived from engine channel base */ -static mrcp_engine_channel_t* flite_synth_engine_channel_create(mrcp_engine_t *engine, apr_pool_t *pool) -{ - mpf_stream_capabilities_t *capabilities; - mpf_termination_t *termination; - - /* create flite synth channel */ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) apr_palloc(pool,sizeof(flite_synth_channel_t)); - - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_engine_channel_create"); - synth_channel->flite_engine = (flite_synth_engine_t *) engine->obj; - synth_channel->speak_request = NULL; // no active speak request in progress - synth_channel->speak_response = NULL; - synth_channel->stop_response = NULL; - synth_channel->synthesizing = FALSE; - synth_channel->paused = FALSE; - synth_channel->pool = pool; - synth_channel->audio_buffer = NULL; - synth_channel->iId = 0; - synth_channel->task = NULL; - synth_channel->msg_pool = NULL; - if(flite_synth_task_create(synth_channel) != TRUE) { - apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "flite_synth_task_create failed"); - return NULL; - } - - capabilities = mpf_source_stream_capabilities_create(pool); - mpf_codec_capabilities_add( - &capabilities->codecs, - MPF_SAMPLE_RATE_8000 | MPF_SAMPLE_RATE_16000, - "LPCM"); - - /* create media termination */ - termination = mrcp_engine_audio_termination_create( - synth_channel, /* object to associate */ - &audio_stream_vtable, /* virtual methods table of audio stream */ - capabilities, /* stream capabilities */ - pool); /* pool to allocate memory from */ - - /* create engine channel base */ - synth_channel->channel = mrcp_engine_channel_create( - engine, /* engine */ - &channel_vtable, /* virtual methods table of engine channel */ - synth_channel, /* object to associate */ - termination, /* associated media termination */ - pool); /* pool to allocate memory from */ - - if(!synth_channel->channel) { - apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "flite_synth_engine_channel_create failed"); - apt_task_destroy(synth_channel->task); - return NULL; - } - - synth_channel->audio_buffer = mpf_buffer_create(pool); - synth_channel->iId = ++synth_channel->flite_engine->iChannels; - - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_engine_channel_create created channel %d", synth_channel->iId); - return synth_channel->channel; -} - -/** Destroy engine channel */ -static apt_bool_t flite_synth_channel_destroy(mrcp_engine_channel_t *channel) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_destroy - channel %d", synth_channel->iId); - if(synth_channel->task) { - apt_task_destroy(synth_channel->task); - synth_channel->task = NULL; - } - - synth_channel->flite_engine->iChannels--; - return TRUE; -} - -/** Open engine channel (asynchronous response MUST be sent)*/ -static apt_bool_t flite_synth_channel_open(mrcp_engine_channel_t *channel) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_open - channel %d", synth_channel->iId); - - if(synth_channel->task) { - if(apt_task_start(synth_channel->task) == TRUE) { - /* async response will be sent */ - return TRUE; - } - else { - apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "Speak task start failed - channel %d", synth_channel->iId); - } - } - - return mrcp_engine_channel_open_respond(channel,FALSE); -} - -/** Close engine channel (asynchronous response MUST be sent)*/ -static apt_bool_t flite_synth_channel_close(mrcp_engine_channel_t *channel) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_close - channel %d", synth_channel->iId); - - if(synth_channel->task) { - if(apt_task_terminate(synth_channel->task,FALSE) == TRUE) { - /* async response will be sent */ - return TRUE; - } - else { - apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "Speak task terminate failed - channel %d", synth_channel->iId); - } - } - return mrcp_engine_channel_close_respond(channel); -} - -/** Process MRCP channel request (asynchronous response MUST be sent)*/ -static apt_bool_t flite_synth_channel_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *request) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - mrcp_message_t *response = mrcp_response_create(request,request->pool); - apt_bool_t processed = FALSE; - - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_request_process - channel %d", synth_channel->iId); - - switch(request->start_line.method_id) { - case SYNTHESIZER_SET_PARAMS: - break; - case SYNTHESIZER_GET_PARAMS: - break; - case SYNTHESIZER_SPEAK: - processed = flite_synth_channel_speak(channel,request,response); - break; - case SYNTHESIZER_STOP: - processed = flite_synth_channel_stop(channel,request,response); - break; - case SYNTHESIZER_PAUSE: - processed = flite_synth_channel_pause(channel,request,response); - break; - case SYNTHESIZER_RESUME: - processed = flite_synth_channel_resume(channel,request,response); - break; - case SYNTHESIZER_BARGE_IN_OCCURRED: - processed = flite_synth_channel_stop(channel,request,response); - break; - case SYNTHESIZER_CONTROL: - break; - case SYNTHESIZER_DEFINE_LEXICON: - break; - default: - break; - } - if(processed == FALSE) { - /* send asynchronous response for not handled request */ - mrcp_engine_channel_message_send(channel,response); - } - return TRUE; -} - -/** Process SPEAK request */ -static apt_bool_t synth_response_construct(mrcp_message_t *response, mrcp_status_code_e status_code, mrcp_synth_completion_cause_e completion_cause) -{ - mrcp_synth_header_t *synth_header = mrcp_resource_header_prepare(response); - if(!synth_header) { - return FALSE; - } - - response->start_line.status_code = status_code; - synth_header->completion_cause = completion_cause; - mrcp_resource_header_property_add(response,SYNTHESIZER_HEADER_COMPLETION_CAUSE); - return TRUE; -} - -/** Process SPEAK request */ -static apt_bool_t flite_synth_channel_speak(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response) -{ - mrcp_generic_header_t *generic_header; - const char *content_type = NULL; - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_task_msg_t *msg = 0; - flite_speak_msg_t *flite_msg = 0; - apt_log(APT_LOG_MARK, APT_PRIO_INFO, "flite_synth_channel_speak - channel %d", synth_channel->iId); - - generic_header = mrcp_generic_header_get(request); - if(generic_header) { - /* content-type must be specified */ - if(mrcp_generic_header_property_check(request,GENERIC_HEADER_CONTENT_TYPE) == TRUE) { - content_type = generic_header->content_type.buf; - } - } - if(!content_type) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Content-Type"); - synth_response_construct(response,MRCP_STATUS_CODE_MISSING_PARAM,SYNTHESIZER_COMPLETION_CAUSE_ERROR); - return FALSE; - } - - /* Flite currently supports only text/plain (no SSML) */ - if(strstr(content_type,"text") == NULL) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Not Supported Content-Type [%s]",content_type); - synth_response_construct(response,MRCP_STATUS_CODE_UNSUPPORTED_PARAM_VALUE,SYNTHESIZER_COMPLETION_CAUSE_ERROR); - return FALSE; - } - - synth_channel->speak_request = request; - synth_channel->speak_response = response; - - msg = apt_task_msg_acquire(synth_channel->msg_pool); - msg->type = TASK_MSG_USER; - flite_msg = (flite_speak_msg_t*) msg->data; - flite_msg->channel = synth_channel; - flite_msg->request = request; - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG, "Send signal to start speech synthesis - channel:%d", synth_channel->iId); - if(apt_task_msg_signal(synth_channel->task,msg) != TRUE) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING, "Failed to send signal to start speech synthesis - channel:%d", synth_channel->iId); - synth_channel->speak_request = NULL; - synth_channel->speak_response = NULL; - synth_response_construct(response,MRCP_STATUS_CODE_METHOD_FAILED,SYNTHESIZER_COMPLETION_CAUSE_ERROR); - return FALSE; - } - return TRUE; -} - -static apt_bool_t flite_speak(apt_task_t *task, apt_task_msg_t *msg) -{ - flite_speak_msg_t *flite_msg = (flite_speak_msg_t*)msg->data; - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) flite_msg->channel; - cst_wave *wave = NULL; - cst_voice *voice = NULL; - apr_time_t start = 0; - apr_time_t elapsed = 0; - apr_time_t stamp = 0; - apt_str_t *body; - mrcp_message_t *response; - - apr_uint16_t rate = 8000; - const mpf_codec_descriptor_t * descriptor = mrcp_engine_source_stream_codec_get(synth_channel->channel); - if(descriptor) { - rate = descriptor->sampling_rate; - } - body = &synth_channel->speak_request->body; - - response = synth_channel->speak_response; - synth_channel->speak_response = NULL; - - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "< flite_speak_msg_process speak - channel %d", synth_channel->iId); - - /* just sequential stuff */ - start = apr_time_now(); /* in microsec */ - if(!body->length) { - synth_channel->speak_request = NULL; - synth_response_construct(response,MRCP_STATUS_CODE_MISSING_PARAM,SYNTHESIZER_COMPLETION_CAUSE_ERROR); - mrcp_engine_channel_message_send(synth_channel->channel,response); - return FALSE; - } - - voice = flite_voices_best_match_get( - synth_channel->flite_engine->voices, - synth_channel->speak_request); - if(!voice) { - /* error case: no voice found, appropriate respond must be sent */ - synth_channel->speak_request = NULL; - synth_response_construct(response,MRCP_STATUS_CODE_METHOD_FAILED,SYNTHESIZER_COMPLETION_CAUSE_ERROR); - mrcp_engine_channel_message_send(synth_channel->channel,response); - return FALSE; - } - - /* - TODO - create small units of text from synth_channel->speak_request->body.buf ( , . ? ! but ... - synthesize small unit and store in audio_buffer - check for stop - pause resume state could improve performance - you can "pause" generating new speech from a unit of text - by checking the (decreasing) size of the audio_buffer - no need to generate more speech samples than can be listened to... - */ - - /* send in-progress response and start synthesizing */ - response->start_line.request_state = MRCP_REQUEST_STATE_INPROGRESS; - mrcp_engine_channel_message_send(synth_channel->channel,response); - - synth_channel->synthesizing = TRUE; - wave = flite_text_to_wave(body->buf, voice); - if(wave && cst_wave_num_samples(wave)) { - int generated = (cst_wave_num_samples(wave)/cst_wave_sample_rate(wave)*1000); - stamp = apr_time_now(); - elapsed = (stamp - start)/1000; - apt_log(APT_LOG_MARK, APT_PRIO_INFO, "TTS (chan %d) took %"APR_TIME_T_FMT" to generate %d of speech (in millisec)", synth_channel->iId, elapsed, generated); - - if(rate != 16000) { - cst_wave_resample(wave, rate); - elapsed = (apr_time_now() - stamp)/1000; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "TTS resampling to %d on (chan %d) took %"APR_TIME_T_FMT" millisec", rate, synth_channel->iId, elapsed); - } - mpf_buffer_audio_write(synth_channel->audio_buffer, cst_wave_samples(wave), cst_wave_num_samples(wave) * 2); - delete_wave(wave); - } - - /* this will notify the callback that feeds the client that synthesis is complete */ - mpf_buffer_event_write(synth_channel->audio_buffer, MEDIA_FRAME_TYPE_EVENT); - synth_channel->synthesizing = FALSE; - - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "> flite_speak_msg_process speak - end of TTS - %d", synth_channel->iId); - return TRUE; -} - -static APR_INLINE flite_synth_channel_t* flite_synth_channel_get(apt_task_t *task) -{ - apt_consumer_task_t *consumer_task = apt_task_object_get(task); - return apt_consumer_task_object_get(consumer_task); -} - -static void flite_on_start(apt_task_t *task) -{ - flite_synth_channel_t *synth_channel = flite_synth_channel_get(task); - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "Speak task started - channel %d", synth_channel->iId); - mrcp_engine_channel_open_respond(synth_channel->channel,TRUE); -} - -static void flite_on_terminate(apt_task_t *task) -{ - flite_synth_channel_t *synth_channel = flite_synth_channel_get(task); - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "Speak task terminated - channel %d", synth_channel->iId); - mrcp_engine_channel_close_respond(synth_channel->channel); -} - -/** Process STOP request */ -static apt_bool_t flite_synth_channel_stop(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_stop - channel %d", synth_channel->iId); - /* store the request, make sure there is no more activity and only then send the response */ - - synth_channel->stop_response = response; - return TRUE; -} - -/** Process PAUSE request */ -static apt_bool_t flite_synth_channel_pause(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_pause - channel %d", synth_channel->iId); - - synth_channel->paused = TRUE; - /* send asynchronous response */ - mrcp_engine_channel_message_send(channel,response); - return TRUE; -} - -/** Process RESUME request */ -static apt_bool_t flite_synth_channel_resume(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) channel->method_obj; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_resume - channel %d", synth_channel->iId); - - synth_channel->paused = FALSE; - /* send asynchronous response */ - mrcp_engine_channel_message_send(channel,response); - return TRUE; -} - -/** Raise SPEAK-COMPLETE event */ -static apt_bool_t flite_synth_speak_complete_raise(flite_synth_channel_t *synth_channel) -{ - mrcp_message_t *message = 0; - mrcp_synth_header_t * synth_header = 0; - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_speak_complete_raise - channel %d", synth_channel->iId); - - if (!synth_channel->speak_request) { - return FALSE; - } - - message = mrcp_event_create( - synth_channel->speak_request, - SYNTHESIZER_SPEAK_COMPLETE, - synth_channel->speak_request->pool); - if (!message) { - return FALSE; - } - - /* get/allocate synthesizer header */ - synth_header = (mrcp_synth_header_t *) mrcp_resource_header_prepare(message); - if (synth_header) { - /* set completion cause */ - synth_header->completion_cause = SYNTHESIZER_COMPLETION_CAUSE_NORMAL; - mrcp_resource_header_property_add(message,SYNTHESIZER_HEADER_COMPLETION_CAUSE); - } - /* set request state */ - message->start_line.request_state = MRCP_REQUEST_STATE_COMPLETE; - - synth_channel->speak_request = NULL; - /* send asynch event */ - return mrcp_engine_channel_message_send(synth_channel->channel,message); -} - -/** Callback is called from MPF engine context to read/get new frame */ -static apt_bool_t flite_synth_stream_read(mpf_audio_stream_t *stream, mpf_frame_t *frame) -{ - flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) stream->obj; - if(synth_channel->stop_response && synth_channel->synthesizing == FALSE) { - /* send asynchronous response to STOP request */ - mrcp_message_t *stop_response = synth_channel->stop_response; - synth_channel->stop_response = NULL; - synth_channel->speak_request = NULL; - synth_channel->paused = FALSE; - mrcp_engine_channel_message_send(synth_channel->channel,stop_response); - return TRUE; - } - - /* check if there is active SPEAK request and it isn't in paused state */ - if(synth_channel->speak_request && synth_channel->paused == FALSE) { - /* normal processing */ - mpf_buffer_frame_read(synth_channel->audio_buffer,frame); -#if 0 - apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_stream_read - channel %d - size %d", synth_channel->iId, mpf_buffer_get_size(synth_channel->audio_buffer)); -#endif - - if((frame->type & MEDIA_FRAME_TYPE_EVENT) == MEDIA_FRAME_TYPE_EVENT) { - frame->type &= ~MEDIA_FRAME_TYPE_EVENT; - flite_synth_speak_complete_raise(synth_channel); - } - } - return TRUE; -} diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am b/libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am deleted file mode 100644 index 1f0edf7d4e..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) \ - $(UNIMRCP_APU_INCLUDES) \ - $(UNIMRCP_SPHINXBASE_INCLUDES) \ - $(UNIMRCP_POCKETSPHINX_INCLUDES) - -plugin_LTLIBRARIES = mrcppocketsphinx.la - -mrcppocketsphinx_la_SOURCES = src/mrcp_pocketsphinx.c \ - src/pocketsphinx_properties.c -mrcppocketsphinx_la_LDFLAGS = -module $(PLUGIN_LT_VERSION) -mrcppocketsphinx_la_LIBADD = $(UNIMRCP_POCKETSPHINX_LIBS) $(UNIMRCP_SPHINXBASE_LIBS) -lm - - -dictionary: - !(test -f $(UNIMRCP_POCKETSPHINX_MODELS)/lm/cmudict.0.6d) || \ - $(INSTALL) -m 644 $(UNIMRCP_POCKETSPHINX_MODELS)/lm/cmudict.0.6d $(datadir)/default.dic - -model: - !(test -d $(UNIMRCP_POCKETSPHINX_MODELS)/hmm/wsj1/) || ($(mkinstalldirs) $(datadir)/wsj1; \ - $(INSTALL) -m 644 $(UNIMRCP_POCKETSPHINX_MODELS)/hmm/wsj1/* $(datadir)/wsj1) - -install-data-local: - test -d $(confdir) || $(mkinstalldirs) $(confdir) - test -f $(confdir)/pocketsphinx.xml || $(INSTALL) -m 644 conf/pocketsphinx.xml $(confdir) - test -f $(datadir)/default.dic || $(MAKE) dictionary - test -d $(datadir)/wsj1 || $(MAKE) model diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/conf/pocketsphinx.xml b/libs/unimrcp/plugins/mrcp-pocketsphinx/conf/pocketsphinx.xml deleted file mode 100644 index 6d7bfa1ef5..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/conf/pocketsphinx.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/include/pocketsphinx_properties.h b/libs/unimrcp/plugins/mrcp-pocketsphinx/include/pocketsphinx_properties.h deleted file mode 100644 index 7ec96e80a9..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/include/pocketsphinx_properties.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2008-2010 Arsen Chaloyan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id: pocketsphinx_properties.h 1743 2010-07-12 08:04:46Z achaloyan $ - */ - -#ifndef POCKETSPHINX_PROPERTIES_H -#define POCKETSPHINX_PROPERTIES_H - -/** - * @file pocketsphinx_properties.h - * @brief PocketSphinx Properties - */ - -#include "apt_dir_layout.h" - -APT_BEGIN_EXTERN_C - -/** Enumeration of PocketSphinx models */ -typedef enum { - POCKETSPHINX_MODEL_NARROWBAND, /**< narrowband model */ - POCKETSPHINX_MODEL_WIDEBAND /**< wideband model */ -} pocketsphinx_model_e; - -/** Declaration of PocketSphinx properties */ -typedef struct pocketsphinx_properties_t pocketsphinx_properties_t; - -/** PocketSphinx properties */ -struct pocketsphinx_properties_t { - /** Data directory */ - const char *data_dir; - /** Path to dictionary file */ - const char *dictionary; - /** Path to narrowband model */ - const char *model_8k; - /** Path to wideband model */ - const char *model_16k; - /** Preferred (default) model */ - pocketsphinx_model_e preferred_model; - - /** Sensitivity level */ - apr_size_t sensitivity_level; - /** Activity timeout (timeout to be used to switch to the activity state) */ - apr_size_t activity_timeout; - /** Inactivity timeout (timeout to be used to switch to the inactivity state) */ - apr_size_t inactivity_timeout; - - /** Noinput timeout */ - apr_size_t no_input_timeout; - /** Recognition timeout */ - apr_size_t recognition_timeout; - /** Partial result checking timeout */ - apr_size_t partial_result_timeout; - - /** Whether to save waveform or not */ - apt_bool_t save_waveform; - /** Directory to save waveform in */ - const char *save_waveform_dir; -}; - -/** Load PocketSphinx properties */ -apt_bool_t pocketsphinx_properties_load(pocketsphinx_properties_t *properties, - const char *file_path, - const apt_dir_layout_t *dir_layout, - apr_pool_t *pool); - -APT_END_EXTERN_C - -#endif /* POCKETSPHINX_PROPERTIES_H */ diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.2008.vcproj b/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.2008.vcproj deleted file mode 100644 index c12369df8e..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.2008.vcproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj b/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj deleted file mode 100644 index 77ed146b54..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/mrcppocketsphinx.vcproj +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c b/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c deleted file mode 100644 index 2f1e3a90d9..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c +++ /dev/null @@ -1,1002 +0,0 @@ -/* - * Copyright 2008-2010 Arsen Chaloyan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id: mrcp_pocketsphinx.c 1787 2010-09-23 12:28:32Z achaloyan $ - */ - -/* - * Mandatory rules concerning plugin implementation. - * 1. Each plugin MUST implement a plugin/engine creator function - * with the exact signature and name (the main entry point) - * MRCP_PLUGIN_DECLARE(mrcp_engine_t*) mrcp_plugin_create(apr_pool_t *pool) - * 2. Each plugin MUST declare its version number - * MRCP_PLUGIN_VERSION_DECLARE - * 3. One and only one response MUST be sent back to the received request. - * 4. Methods (callbacks) of the MRCP engine channel MUST not block. - * (asynchronous response can be sent from the context of other thread) - * 5. Methods (callbacks) of the MPF engine stream MUST not block. - */ - -#include -#include -#include -#include -#include -#include "mrcp_recog_engine.h" -#include "mpf_activity_detector.h" -#include "pocketsphinx_properties.h" -#include "apt_log.h" - -#define POCKETSPHINX_CONFFILE_NAME "pocketsphinx.xml" - -#define RECOGNIZER_SIDRES(recognizer) (recognizer)->channel->id.buf, "pocketsphinx" - -typedef struct pocketsphinx_engine_t pocketsphinx_engine_t; -typedef struct pocketsphinx_recognizer_t pocketsphinx_recognizer_t; - -/** Methods of recognition engine */ -static apt_bool_t pocketsphinx_engine_destroy(mrcp_engine_t *engine); -static apt_bool_t pocketsphinx_engine_open(mrcp_engine_t *engine); -static apt_bool_t pocketsphinx_engine_close(mrcp_engine_t *engine); -static mrcp_engine_channel_t* pocketsphinx_engine_recognizer_create(mrcp_engine_t *engine, apr_pool_t *pool); - -static const struct mrcp_engine_method_vtable_t engine_vtable = { - pocketsphinx_engine_destroy, - pocketsphinx_engine_open, - pocketsphinx_engine_close, - pocketsphinx_engine_recognizer_create -}; - - -/** Methods of recognition channel (recognizer) */ -static apt_bool_t pocketsphinx_recognizer_destroy(mrcp_engine_channel_t *channel); -static apt_bool_t pocketsphinx_recognizer_open(mrcp_engine_channel_t *channel); -static apt_bool_t pocketsphinx_recognizer_close(mrcp_engine_channel_t *channel); -static apt_bool_t pocketsphinx_recognizer_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *request); - -static const struct mrcp_engine_channel_method_vtable_t channel_vtable = { - pocketsphinx_recognizer_destroy, - pocketsphinx_recognizer_open, - pocketsphinx_recognizer_close, - pocketsphinx_recognizer_request_process -}; - -/** Methods of audio stream to recognize */ -static apt_bool_t pocketsphinx_stream_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame); - -static const mpf_audio_stream_vtable_t audio_stream_vtable = { - NULL, /* destroy */ - NULL, /* open_rx */ - NULL, /* close_rx */ - NULL, /* read_frame */ - NULL, /* open_tx */ - NULL, /* close_tx */ - pocketsphinx_stream_write -}; - -/** Pocketsphinx engine (engine is an aggregation of recognizers) */ -struct pocketsphinx_engine_t { - /* Engine base */ - mrcp_engine_t *base; - /** Properties loaded from config file */ - pocketsphinx_properties_t properties; -}; - -/** Pocketsphinx channel (recognizer) */ -struct pocketsphinx_recognizer_t { - /** Engine channel base */ - mrcp_engine_channel_t *channel; - - /** Actual recognizer object */ - ps_decoder_t *decoder; - /** Configuration */ - cmd_ln_t *config; - /** Recognizer properties coppied from default engine properties */ - pocketsphinx_properties_t properties; - /** Whether input timer has been started or not */ - apt_bool_t is_input_timer_on; - /** Noinput timeout */ - apr_size_t no_input_timeout; - /** Whether recognition timer has been started or not */ - apt_bool_t is_recognition_timer_on; - /** Recognition timeout */ - apr_size_t recognition_timeout; - /** Timeout elapsed since the last partial result checking */ - apr_size_t partial_result_timeout; - /** Last (partially) recognized result */ - const char *last_result; - /** Active grammar identifier (content-id) */ - const char *grammar_id; - /** Table of defined grammars (key=content-id, value=grammar-file-path) */ - apr_table_t *grammar_table; - /** File to write waveform to if save_waveform is on */ - apr_file_t *waveform; - - /** Voice activity detector */ - mpf_activity_detector_t *detector; - - /** Thread to run recognition in */ - apr_thread_t *thread; - /** Conditional wait object */ - apr_thread_cond_t *wait_object; - /** Mutex of the wait object */ - apr_thread_mutex_t *mutex; - - /** Pending request from client stack to recognizer */ - mrcp_message_t *request; - /** Pending event from mpf layer to recognizer */ - mrcp_message_t *complete_event; - /** In-progress RECOGNIZE request */ - mrcp_message_t *inprogress_recog; - /** Pending STOP response */ - mrcp_message_t *stop_response; - /** Is recognition channel being closed */ - apt_bool_t close_requested; - /** Flag to prevent race condition when checking if a message is present */ - apt_bool_t message_waiting; -}; - -static void* APR_THREAD_FUNC pocketsphinx_recognizer_run(apr_thread_t *thread, void *data); - -/** Declare this macro to set plugin version */ -MRCP_PLUGIN_VERSION_DECLARE - -/** Declare this macro to use log routine of the server, plugin is loaded from */ -MRCP_PLUGIN_LOGGER_IMPLEMENT - -/** Create pocketsphinx engine (engine is an aggregation of recognizers) */ -MRCP_PLUGIN_DECLARE(mrcp_engine_t*) mrcp_plugin_create(apr_pool_t *pool) -{ - pocketsphinx_engine_t *engine = apr_palloc(pool,sizeof(pocketsphinx_engine_t)); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create PocketSphinx Engine"); - - /* create engine base */ - engine->base = mrcp_engine_create( - MRCP_RECOGNIZER_RESOURCE, /* MRCP resource identifier */ - engine, /* object to associate */ - &engine_vtable, /* virtual methods table of engine */ - pool); /* pool to allocate memory from */ - return engine->base; -} - -/** Destroy pocketsphinx engine */ -static apt_bool_t pocketsphinx_engine_destroy(mrcp_engine_t *engine_base) -{ - return TRUE; -} - -/** Open pocketsphinx engine */ -static apt_bool_t pocketsphinx_engine_open(mrcp_engine_t *engine_base) -{ - pocketsphinx_engine_t *engine = engine_base->obj; - const apt_dir_layout_t *dir_layout = engine_base->dir_layout; - - char *file_path = NULL; - apr_filepath_merge(&file_path,dir_layout->conf_dir_path,POCKETSPHINX_CONFFILE_NAME,0,engine_base->pool); - - /* load properties */ - pocketsphinx_properties_load(&engine->properties,file_path,dir_layout,engine_base->pool); - return mrcp_engine_open_respond(engine_base,TRUE); -} - -/** Close pocketsphinx engine */ -static apt_bool_t pocketsphinx_engine_close(mrcp_engine_t *engine_base) -{ - return mrcp_engine_close_respond(engine_base); -} - -/** Create pocketsphinx recognizer */ -static mrcp_engine_channel_t* pocketsphinx_engine_recognizer_create(mrcp_engine_t *engine_base, apr_pool_t *pool) -{ - mpf_stream_capabilities_t *capabilities; - mpf_termination_t *termination; - mrcp_engine_channel_t *channel; - pocketsphinx_engine_t *engine = engine_base->obj; - - /* create pocketsphinx recognizer */ - pocketsphinx_recognizer_t *recognizer = apr_palloc(pool,sizeof(pocketsphinx_recognizer_t)); - recognizer->decoder = NULL; - recognizer->config = NULL; - recognizer->is_input_timer_on = FALSE; - recognizer->no_input_timeout = 0; - recognizer->is_recognition_timer_on = FALSE; - recognizer->recognition_timeout = 0; - recognizer->partial_result_timeout = 0; - recognizer->last_result = NULL; - recognizer->detector = NULL; - recognizer->thread = NULL; - recognizer->wait_object = NULL; - recognizer->mutex = NULL; - recognizer->request = NULL; - recognizer->complete_event = NULL; - recognizer->inprogress_recog = FALSE; - recognizer->stop_response = NULL; - recognizer->close_requested = FALSE; - recognizer->grammar_id = NULL; - recognizer->grammar_table = apr_table_make(pool,1); - recognizer->waveform = NULL; - recognizer->message_waiting = FALSE; - - /* copy default properties loaded from config */ - recognizer->properties = engine->properties; - - capabilities = mpf_sink_stream_capabilities_create(pool); - mpf_codec_capabilities_add( - &capabilities->codecs, - MPF_SAMPLE_RATE_8000 | MPF_SAMPLE_RATE_16000, - "LPCM"); - - /* create media termination */ - termination = mrcp_engine_audio_termination_create( - recognizer, /* object to associate */ - &audio_stream_vtable, /* virtual methods table of audio stream */ - capabilities, /* stream capabilities */ - pool); /* pool to allocate memory from */ - - /* create engine channel base */ - channel = mrcp_engine_channel_create( - engine_base, /* engine */ - &channel_vtable, /* virtual methods table of engine channel */ - recognizer, /* object to associate */ - termination, /* associated media termination */ - pool); /* pool to allocate memory from */ - - apr_thread_mutex_create(&recognizer->mutex,APR_THREAD_MUTEX_DEFAULT,channel->pool); - apr_thread_cond_create(&recognizer->wait_object,channel->pool); - - recognizer->channel = channel; - return channel; -} - -/** Destroy pocketsphinx recognizer */ -static apt_bool_t pocketsphinx_recognizer_destroy(mrcp_engine_channel_t *channel) -{ - pocketsphinx_recognizer_t *recognizer = channel->method_obj; - if(recognizer->mutex) { - apr_thread_mutex_destroy(recognizer->mutex); - recognizer->mutex = NULL; - } - if(recognizer->wait_object) { - apr_thread_cond_destroy(recognizer->wait_object); - recognizer->wait_object = NULL; - } - return TRUE; -} - -/** Open pocketsphinx recognizer (asynchronous response MUST be sent) */ -static apt_bool_t pocketsphinx_recognizer_open(mrcp_engine_channel_t *channel) -{ - apr_status_t rv; - pocketsphinx_recognizer_t *recognizer = channel->method_obj; - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Channel "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - - /* Launch a thread to run recognition in */ - rv = apr_thread_create(&recognizer->thread,NULL,pocketsphinx_recognizer_run,recognizer,channel->pool); - if(rv != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Failed to Launch Thread "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - return mrcp_engine_channel_open_respond(channel,FALSE); - } - - return TRUE; -} - -/** Close pocketsphinx recognizer (asynchronous response MUST be sent)*/ -static apt_bool_t pocketsphinx_recognizer_close(mrcp_engine_channel_t *channel) -{ - pocketsphinx_recognizer_t *recognizer = channel->method_obj; - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close Channel "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - if(recognizer->thread) { - apr_status_t s; - apr_thread_mutex_lock(recognizer->mutex); - - /* Signal recognition thread to terminate */ - recognizer->close_requested = TRUE; - recognizer->message_waiting = TRUE; - apr_thread_cond_signal(recognizer->wait_object); - - apr_thread_mutex_unlock(recognizer->mutex); - - /* Wait for thread to be finally terminated */ - apr_thread_join(&s,recognizer->thread); - recognizer->thread = NULL; - } - - return mrcp_engine_channel_close_respond(channel); -} - -/** Process MRCP request (asynchronous response MUST be sent)*/ -static apt_bool_t pocketsphinx_recognizer_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *request) -{ - pocketsphinx_recognizer_t *recognizer = channel->method_obj; - - /* Store request and signal recognition thread to process the request */ - apr_thread_mutex_lock(recognizer->mutex); - recognizer->request = request; - recognizer->message_waiting = TRUE; - apr_thread_cond_signal(recognizer->wait_object); - apr_thread_mutex_unlock(recognizer->mutex); - return TRUE; -} - -/** Initialize pocketsphinx decoder [RECOG] */ -static apt_bool_t pocketsphinx_decoder_init(pocketsphinx_recognizer_t *recognizer, const char *grammar) -{ - const mpf_codec_descriptor_t *descriptor = mrcp_engine_sink_stream_codec_get(recognizer->channel); - const char *model = recognizer->properties.model_8k; - const char *rate = "8000"; - if(descriptor && descriptor->sampling_rate == 16000) { - model = recognizer->properties.model_16k; - rate = "16000"; - } - - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Init Config rate [%s] dictionary [%s] "APT_SIDRES_FMT, - rate, - recognizer->properties.dictionary, - RECOGNIZER_SIDRES(recognizer)); - recognizer->config = cmd_ln_init(recognizer->config, ps_args(), FALSE, - "-samprate", rate, - "-hmm", model, - "-jsgf", grammar, - "-dict", recognizer->properties.dictionary, - "-frate", "50", - "-silprob", "0.005", - NULL); - if(!recognizer->config) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Init Config "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - return FALSE; - } - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Init Decoder "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - if(recognizer->decoder) { - if(ps_reinit(recognizer->decoder,recognizer->config) < 0) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Reinit Decoder "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - return FALSE; - } - } - else { - recognizer->decoder = ps_init(recognizer->config); - if(!recognizer->decoder) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Init Decoder "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - return FALSE; - } - } - - if(!recognizer->detector) { - recognizer->detector = mpf_activity_detector_create(recognizer->channel->pool); - mpf_activity_detector_level_set(recognizer->detector,recognizer->properties.sensitivity_level); - mpf_activity_detector_speech_timeout_set(recognizer->detector,recognizer->properties.activity_timeout); - mpf_activity_detector_silence_timeout_set(recognizer->detector,recognizer->properties.inactivity_timeout); - } - return TRUE; -} - -/** Build pocketsphinx recognized result [RECOG] */ -static apt_bool_t pocketsphinx_result_build(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *message) -{ - apt_str_t *body = &message->body; - if(!recognizer->last_result || !recognizer->grammar_id) { - return FALSE; - } - - body->buf = apr_psprintf(message->pool, - "\n" - "\n" - " \n" - " %s\n" - " %s\n" - " \n" - "\n", - recognizer->grammar_id, - recognizer->grammar_id, - 99, - recognizer->last_result, - recognizer->last_result); - if(body->buf) { - mrcp_generic_header_t *generic_header; - generic_header = mrcp_generic_header_prepare(message); - if(generic_header) { - /* set content type */ - apt_string_assign(&generic_header->content_type,"application/x-nlsml",message->pool); - mrcp_generic_header_property_add(message,GENERIC_HEADER_CONTENT_TYPE); - } - - body->length = strlen(body->buf); - } - return TRUE; -} - -/** Clear pocketsphinx grammars [RECOG] */ -static apt_bool_t pocketsphinx_grammars_clear(pocketsphinx_recognizer_t *recognizer) -{ - const apr_array_header_t *tarr = apr_table_elts(recognizer->grammar_table); - const apr_table_entry_t *telts = (const apr_table_entry_t*)tarr->elts; - int i; - for(i = 0; i < tarr->nelts; i++) { - const char *grammar_file_path = telts[i].val; - if(grammar_file_path) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove Grammar File [%s] "APT_SIDRES_FMT, - grammar_file_path,RECOGNIZER_SIDRES(recognizer)); - apr_file_remove(grammar_file_path,recognizer->channel->pool); - } - } - apr_table_clear(recognizer->grammar_table); - return TRUE; -} - -/** Load pocketsphinx grammar [RECOG] */ -static mrcp_status_code_e pocketsphinx_grammar_load(pocketsphinx_recognizer_t *recognizer, const char *content_id, const char *content_type, const apt_str_t *content) -{ - /* load grammar */ - mrcp_engine_channel_t *channel = recognizer->channel; - const apt_dir_layout_t *dir_layout = channel->engine->dir_layout; - const char *grammar_file_path = NULL; - const char *grammar_file_name = NULL; - apr_file_t *fd = NULL; - apr_status_t rv; - apr_size_t size; - - /* only JSGF grammar is supported */ - if(strstr(content_type,"jsgf") == NULL) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Not Supported Content-Type [%s] "APT_SIDRES_FMT, - content_type,RECOGNIZER_SIDRES(recognizer)); - return MRCP_STATUS_CODE_UNSUPPORTED_PARAM_VALUE; - } - - grammar_file_name = apr_psprintf(channel->pool,"%s-%s.gram",channel->id.buf,content_id); - grammar_file_path = apt_datadir_filepath_get(dir_layout,grammar_file_name,channel->pool); - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Grammar File [%s] "APT_SIDRES_FMT, - grammar_file_path,RECOGNIZER_SIDRES(recognizer)); - rv = apr_file_open(&fd,grammar_file_path,APR_CREATE|APR_TRUNCATE|APR_WRITE|APR_BINARY, - APR_OS_DEFAULT,channel->pool); - if(rv != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Open Grammar File to Write [%s] "APT_SIDRES_FMT, - grammar_file_path,RECOGNIZER_SIDRES(recognizer)); - return MRCP_STATUS_CODE_METHOD_FAILED; - } - - size = content->length; - apr_file_write(fd,content->buf,&size); - apr_file_close(fd); - - /* init pocketsphinx decoder */ - if(pocketsphinx_decoder_init(recognizer,grammar_file_path) != TRUE) { - apr_file_remove(grammar_file_path,channel->pool); - return MRCP_STATUS_CODE_METHOD_FAILED; - } - recognizer->grammar_id = content_id; - apr_table_setn(recognizer->grammar_table,content_id,grammar_file_path); - return MRCP_STATUS_CODE_SUCCESS; -} - -/** Unload pocketsphinx grammar [RECOG] */ -static mrcp_status_code_e pocketsphinx_grammar_unload(pocketsphinx_recognizer_t *recognizer, const char *content_id) -{ - /* unload grammar */ - const char *grammar_file_path = apr_table_get(recognizer->grammar_table,content_id); - if(!grammar_file_path) { - return MRCP_STATUS_CODE_ILLEGAL_PARAM_VALUE; - } - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Remove Grammar File [%s] "APT_SIDRES_FMT, - grammar_file_path,RECOGNIZER_SIDRES(recognizer)); - apr_file_remove(grammar_file_path,recognizer->channel->pool); - apr_table_unset(recognizer->grammar_table,content_id); - return MRCP_STATUS_CODE_SUCCESS; -} - -/** Process DEFINE-GRAMMAR request [RECOG] */ -static apt_bool_t pocketsphinx_define_grammar(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response) -{ - const char *content_type = NULL; - const char *content_id = NULL; - mrcp_engine_channel_t *channel = recognizer->channel; - - mrcp_generic_header_t *generic_header = mrcp_generic_header_get(request); - mrcp_recog_header_t *recog_header = mrcp_resource_header_prepare(response); - if(!generic_header || !recog_header) { - return FALSE; - } - - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_SUCCESS; - mrcp_resource_header_property_add(response,RECOGNIZER_HEADER_COMPLETION_CAUSE); - - /* content-id must be specified */ - if(mrcp_generic_header_property_check(request,GENERIC_HEADER_CONTENT_ID) == TRUE) { - content_id = generic_header->content_id.buf; - } - if(!content_id) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Content-Id "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - response->start_line.status_code = MRCP_STATUS_CODE_MISSING_PARAM; - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - - if(mrcp_generic_header_property_check(request,GENERIC_HEADER_CONTENT_LENGTH) == TRUE && - generic_header->content_length) { - /* content-type must be specified */ - if(mrcp_generic_header_property_check(request,GENERIC_HEADER_CONTENT_TYPE) == TRUE) { - content_type = generic_header->content_type.buf; - } - - if(!content_type) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Content-Type "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - response->start_line.status_code = MRCP_STATUS_CODE_MISSING_PARAM; - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - - response->start_line.status_code = pocketsphinx_grammar_load(recognizer,content_id,content_type,&request->body); - if(response->start_line.status_code != MRCP_STATUS_CODE_SUCCESS) { - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - } - else { - response->start_line.status_code = pocketsphinx_grammar_unload(recognizer,content_id); - if(response->start_line.status_code != MRCP_STATUS_CODE_SUCCESS) { - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - } - - /* send asynchronous response */ - mrcp_engine_channel_message_send(channel,response); - return TRUE; -} - -/** Process RECOGNIZE request [RECOG] */ -static apt_bool_t pocketsphinx_recognize(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response) -{ - const char *content_type = NULL; - mrcp_engine_channel_t *channel = recognizer->channel; - mrcp_recog_header_t *request_recog_header; - mrcp_recog_header_t *response_recog_header = mrcp_resource_header_prepare(response); - mrcp_generic_header_t *generic_header = mrcp_generic_header_get(request); - if(!generic_header || !response_recog_header) { - return FALSE; - } - - /* content-type must be specified */ - if(mrcp_generic_header_property_check(request,GENERIC_HEADER_CONTENT_TYPE) == TRUE) { - content_type = generic_header->content_type.buf; - } - if(!content_type) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Content-Type "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - response->start_line.status_code = MRCP_STATUS_CODE_MISSING_PARAM; - response_recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - - if(strcmp(content_type,"text/uri-list") == 0) { - /* assume the uri-list contains last defined (active) grammar for now */ - } - else { - const char *content_id = NULL; - /* content-id must be specified */ - if(mrcp_generic_header_property_check(request,GENERIC_HEADER_CONTENT_ID) == TRUE) { - content_id = generic_header->content_id.buf; - } - if(!content_id) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Missing Content-Id "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer)); - response->start_line.status_code = MRCP_STATUS_CODE_MISSING_PARAM; - response_recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - - response->start_line.status_code = pocketsphinx_grammar_load(recognizer,content_id,content_type,&request->body); - if(response->start_line.status_code != MRCP_STATUS_CODE_SUCCESS) { - response_recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_GRAM_LOAD_FAILURE; - return FALSE; - } - } - - if(!recognizer->decoder || ps_start_utt(recognizer->decoder, NULL) < 0) { - response->start_line.status_code = MRCP_STATUS_CODE_METHOD_FAILED; - response_recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_ERROR; - mrcp_resource_header_property_add(response,RECOGNIZER_HEADER_COMPLETION_CAUSE); - return FALSE; - } - - recognizer->is_input_timer_on = TRUE; - recognizer->is_recognition_timer_on = FALSE; - /* get recognizer header */ - request_recog_header = mrcp_resource_header_get(request); - if(request_recog_header) { - if(mrcp_resource_header_property_check(request,RECOGNIZER_HEADER_START_INPUT_TIMERS) == TRUE) { - recognizer->is_input_timer_on = request_recog_header->start_input_timers; - } - if(mrcp_resource_header_property_check(request,RECOGNIZER_HEADER_NO_INPUT_TIMEOUT) == TRUE) { - recognizer->properties.no_input_timeout = request_recog_header->no_input_timeout; - } - if(mrcp_resource_header_property_check(request,RECOGNIZER_HEADER_RECOGNITION_TIMEOUT) == TRUE) { - recognizer->properties.recognition_timeout = request_recog_header->recognition_timeout; - } - if(mrcp_resource_header_property_check(request,RECOGNIZER_HEADER_SAVE_WAVEFORM) == TRUE) { - recognizer->properties.save_waveform = request_recog_header->save_waveform; - } - } - - /* check if waveform (utterance) should be saved */ - if(recognizer->properties.save_waveform == TRUE) { - apr_status_t rv; - const char *waveform_file_name = apr_psprintf(channel->pool,"utter-%s-%"MRCP_REQUEST_ID_FMT".pcm", - channel->id.buf, - request->start_line.request_id); - char *waveform_file_path = NULL; - apr_filepath_merge(&waveform_file_path,recognizer->properties.save_waveform_dir, - waveform_file_name,0,channel->pool); - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Waveform File [%s] "APT_SIDRES_FMT, - waveform_file_path,RECOGNIZER_SIDRES(recognizer)); - rv = apr_file_open(&recognizer->waveform,waveform_file_path,APR_CREATE|APR_TRUNCATE|APR_WRITE|APR_BINARY, - APR_OS_DEFAULT,channel->pool); - if(rv != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Open Waveform File to Write [%s] "APT_SIDRES_FMT, - waveform_file_path,RECOGNIZER_SIDRES(recognizer)); - } - } - - response->start_line.request_state = MRCP_REQUEST_STATE_INPROGRESS; - /* send asynchronous response */ - mrcp_engine_channel_message_send(channel,response); - - /* reset */ - mpf_activity_detector_reset(recognizer->detector); - recognizer->no_input_timeout = 0; - recognizer->recognition_timeout = 0; - recognizer->partial_result_timeout = 0; - recognizer->last_result = NULL; - recognizer->complete_event = NULL; - - recognizer->inprogress_recog = request; - return TRUE; -} - -/** Process GET-RESULT request [RECOG] */ -static apt_bool_t pocketsphinx_get_result(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response) -{ - if(pocketsphinx_result_build(recognizer,response) != TRUE) { - response->start_line.status_code = MRCP_STATUS_CODE_METHOD_FAILED; - } - - /* send asynchronous response */ - mrcp_engine_channel_message_send(recognizer->channel,response); - return TRUE; -} - -/** Process START-INPUT-TIMERS request [RECOG] */ -static apt_bool_t pocketsphinx_start_input_timers(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response) -{ - recognizer->is_input_timer_on = TRUE; - - /* send asynchronous response */ - mrcp_engine_channel_message_send(recognizer->channel,response); - return TRUE; -} - - -/** Process STOP request [RECOG] */ -static apt_bool_t pocketsphinx_stop(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request, mrcp_message_t *response) -{ - if(recognizer->inprogress_recog) { - /* store pending STOP response for further processing */ - recognizer->stop_response = response; - return TRUE; - } - - /* send asynchronous response */ - mrcp_engine_channel_message_send(recognizer->channel,response); - return TRUE; -} - -/** Process RECOGNITION-COMPLETE event [RECOG] */ -static apt_bool_t pocketsphinx_recognition_complete(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *complete_event) -{ - mrcp_recog_header_t *recog_header; - if(!recognizer->inprogress_recog) { - /* false event */ - return FALSE; - } - - recognizer->inprogress_recog = NULL; - ps_end_utt(recognizer->decoder); - - if(recognizer->waveform) { - apr_file_close(recognizer->waveform); - recognizer->waveform = NULL; - } - - if(recognizer->stop_response) { - /* recognition has been stopped, send STOP response instead */ - mrcp_message_t *response = recognizer->stop_response; - recognizer->stop_response = NULL; - if(recognizer->close_requested == FALSE) { - mrcp_engine_channel_message_send(recognizer->channel,response); - } - return TRUE; - } - - recog_header = mrcp_resource_header_get(complete_event); - if(recog_header->completion_cause == RECOGNIZER_COMPLETION_CAUSE_SUCCESS || - recog_header->completion_cause == RECOGNIZER_COMPLETION_CAUSE_RECOGNITION_TIMEOUT) { - int32 score; - char const *hyp; - char const *uttid; - - hyp = ps_get_hyp(recognizer->decoder, &score, &uttid); - if(hyp && strlen(hyp) > 0) { - int32 prob; - recognizer->last_result = apr_pstrdup(recognizer->channel->pool,hyp); - prob = ps_get_prob(recognizer->decoder, &uttid); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Get Recognition Final Result [%s] Prob [%d] Score [%d] "APT_SIDRES_FMT, - hyp,prob,score,RECOGNIZER_SIDRES(recognizer)); - if(pocketsphinx_result_build(recognizer,complete_event) == TRUE) { - if(recognizer->channel->mrcp_version == MRCP_VERSION_2 && - recog_header->completion_cause == RECOGNIZER_COMPLETION_CAUSE_RECOGNITION_TIMEOUT) { - /* rewrite completion cause for MRCPv2 */ - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_TOO_MUCH_SPEECH_TIMEOUT; - } - } - else { - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_ERROR; - } - } - else { - recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_NO_MATCH; - } - } - - /* send asynchronous event */ - mrcp_engine_channel_message_send(recognizer->channel,complete_event); - return TRUE; -} - -/** Dispatch MRCP request [RECOG] */ -static apt_bool_t pocketsphinx_request_dispatch(pocketsphinx_recognizer_t *recognizer, mrcp_message_t *request) -{ - apt_bool_t processed = FALSE; - mrcp_message_t *response = mrcp_response_create(request,request->pool); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Dispatch Request %s "APT_SIDRES_FMT, - request->start_line.method_name.buf, - RECOGNIZER_SIDRES(recognizer)); - switch(request->start_line.method_id) { - case RECOGNIZER_SET_PARAMS: - break; - case RECOGNIZER_GET_PARAMS: - break; - case RECOGNIZER_DEFINE_GRAMMAR: - processed = pocketsphinx_define_grammar(recognizer,request,response); - break; - case RECOGNIZER_RECOGNIZE: - processed = pocketsphinx_recognize(recognizer,request,response); - break; - case RECOGNIZER_GET_RESULT: - processed = pocketsphinx_get_result(recognizer,request,response); - break; - case RECOGNIZER_START_INPUT_TIMERS: - processed = pocketsphinx_start_input_timers(recognizer,request,response); - break; - case RECOGNIZER_STOP: - processed = pocketsphinx_stop(recognizer,request,response); - break; - default: - break; - } - if(processed == FALSE) { - /* send asynchronous response for non handled request */ - mrcp_engine_channel_message_send(recognizer->channel,response); - } - return TRUE; -} - - -/** Recognition thread [RECOG] */ -static void* APR_THREAD_FUNC pocketsphinx_recognizer_run(apr_thread_t *thread, void *data) -{ - pocketsphinx_recognizer_t *recognizer = data; - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Run Recognition Thread "APT_SIDRES_FMT, RECOGNIZER_SIDRES(recognizer)); - /** Send response to channel_open request */ - mrcp_engine_channel_open_respond(recognizer->channel,TRUE); - - do { - apr_thread_mutex_lock(recognizer->mutex); - /** Wait for MRCP requests */ - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for incoming messages "APT_SIDRES_FMT, RECOGNIZER_SIDRES(recognizer)); - if (!recognizer->message_waiting) { - apr_thread_cond_wait(recognizer->wait_object,recognizer->mutex); - } - recognizer->message_waiting = FALSE; - - if(recognizer->request) { - /* store request message and further dispatch it */ - mrcp_message_t *request = recognizer->request; - recognizer->request = NULL; - pocketsphinx_request_dispatch(recognizer,request); - } - if(recognizer->complete_event) { - /* end of input detected, get recognition result and raise recognition complete event */ - pocketsphinx_recognition_complete(recognizer,recognizer->complete_event); - } - apr_thread_mutex_unlock(recognizer->mutex); - } - while(recognizer->close_requested == FALSE); - - /** Clear all the defined grammars */ - pocketsphinx_grammars_clear(recognizer); - - if(recognizer->decoder) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Free Decoder "APT_SIDRES_FMT, RECOGNIZER_SIDRES(recognizer)); - /** Free pocketsphinx decoder */ - ps_free(recognizer->decoder); - recognizer->decoder = NULL; - } - - /** Exit thread */ - apr_thread_exit(thread,APR_SUCCESS); - return NULL; -} - - - -/* Start of input (utterance) [MPF] */ -static apt_bool_t pocketsphinx_start_of_input(pocketsphinx_recognizer_t *recognizer) -{ - /* create START-OF-INPUT event */ - mrcp_message_t *message = mrcp_event_create( - recognizer->inprogress_recog, - RECOGNIZER_START_OF_INPUT, - recognizer->inprogress_recog->pool); - if(!message) { - return FALSE; - } - - /* start recognition timer */ - recognizer->is_recognition_timer_on = TRUE; - - /* set request state */ - message->start_line.request_state = MRCP_REQUEST_STATE_INPROGRESS; - /* send asynchronous event */ - return mrcp_engine_channel_message_send(recognizer->channel,message); -} - -/* End of input (utterance) [MPF] */ -static apt_bool_t pocketsphinx_end_of_input(pocketsphinx_recognizer_t *recognizer, mrcp_recog_completion_cause_e cause) -{ - mrcp_recog_header_t *recog_header; - /* create RECOGNITION-COMPLETE event */ - mrcp_message_t *message = mrcp_event_create( - recognizer->inprogress_recog, - RECOGNIZER_RECOGNITION_COMPLETE, - recognizer->inprogress_recog->pool); - if(!message) { - return FALSE; - } - - /* get/allocate recognizer header */ - recog_header = mrcp_resource_header_prepare(message); - if(recog_header) { - /* set completion cause */ - recog_header->completion_cause = cause; - mrcp_resource_header_property_add(message,RECOGNIZER_HEADER_COMPLETION_CAUSE); - } - /* set request state */ - message->start_line.request_state = MRCP_REQUEST_STATE_COMPLETE; - - /* signal recognition thread first */ - apr_thread_mutex_lock(recognizer->mutex); - recognizer->complete_event = message; - recognizer->message_waiting = TRUE; - apr_thread_cond_signal(recognizer->wait_object); - apr_thread_mutex_unlock(recognizer->mutex); - return TRUE; -} - -/* Process audio frame [MPF] */ -static apt_bool_t pocketsphinx_stream_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame) -{ - pocketsphinx_recognizer_t *recognizer = stream->obj; - - /* check whether recognition has been started and not completed yet */ - if(recognizer->inprogress_recog && !recognizer->complete_event) { - mpf_detector_event_e det_event; - - /* first check if STOP has been requested */ - if(recognizer->stop_response) { - /* recognition has been stopped -> acknowledge with complete-event */ - pocketsphinx_end_of_input(recognizer,RECOGNIZER_COMPLETION_CAUSE_SUCCESS); - return TRUE; - } - - if(recognizer->waveform) { - /* write utterance to file */ - apr_size_t size = frame->codec_frame.size; - apr_file_write(recognizer->waveform,frame->codec_frame.buffer,&size); - } - - if(ps_process_raw( - recognizer->decoder, - (const int16 *)frame->codec_frame.buffer, - frame->codec_frame.size / sizeof(int16), - FALSE, - FALSE) < 0) { - - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Process Raw Data "APT_SIDRES_FMT, - RECOGNIZER_SIDRES(recognizer)); - } - - recognizer->partial_result_timeout += CODEC_FRAME_TIME_BASE; - if(recognizer->partial_result_timeout == recognizer->properties.partial_result_timeout) { - int32 score; - char const *hyp; - char const *uttid; - - recognizer->partial_result_timeout = 0; - hyp = ps_get_hyp(recognizer->decoder, &score, &uttid); - if(hyp && strlen(hyp) > 0) { - if(recognizer->last_result == NULL || 0 != strcmp(recognizer->last_result, hyp)) { - recognizer->last_result = apr_pstrdup(recognizer->channel->pool,hyp); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Get Recognition Partial Result [%s] Score [%d] "APT_SIDRES_FMT, - hyp,score,RECOGNIZER_SIDRES(recognizer)); - - /* reset input timer as we have partial match now */ - if(score != 0 && recognizer->is_input_timer_on) { - recognizer->is_input_timer_on = FALSE; - } - } - } - } - - if(recognizer->is_input_timer_on == TRUE) { - recognizer->no_input_timeout += CODEC_FRAME_TIME_BASE; - if(recognizer->no_input_timeout == recognizer->properties.no_input_timeout) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Noinput Timeout Elapsed "APT_SIDRES_FMT, - RECOGNIZER_SIDRES(recognizer)); - pocketsphinx_end_of_input(recognizer,RECOGNIZER_COMPLETION_CAUSE_NO_INPUT_TIMEOUT); - return TRUE; - } - } - - if(recognizer->is_recognition_timer_on == TRUE) { - recognizer->recognition_timeout += CODEC_FRAME_TIME_BASE; - if(recognizer->recognition_timeout == recognizer->properties.recognition_timeout) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Recognition Timeout Elapsed "APT_SIDRES_FMT, - RECOGNIZER_SIDRES(recognizer)); - pocketsphinx_end_of_input(recognizer,RECOGNIZER_COMPLETION_CAUSE_RECOGNITION_TIMEOUT); - return TRUE; - } - } - - det_event = mpf_activity_detector_process(recognizer->detector,frame); - switch(det_event) { - case MPF_DETECTOR_EVENT_ACTIVITY: - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Detected Voice Activity "APT_SIDRES_FMT, - RECOGNIZER_SIDRES(recognizer)); - pocketsphinx_start_of_input(recognizer); - break; - case MPF_DETECTOR_EVENT_INACTIVITY: - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Detected Voice Inactivity "APT_SIDRES_FMT, - RECOGNIZER_SIDRES(recognizer)); - pocketsphinx_end_of_input(recognizer,RECOGNIZER_COMPLETION_CAUSE_SUCCESS); - break; - default: - break; - } - } - - return TRUE; -} diff --git a/libs/unimrcp/plugins/mrcp-pocketsphinx/src/pocketsphinx_properties.c b/libs/unimrcp/plugins/mrcp-pocketsphinx/src/pocketsphinx_properties.c deleted file mode 100644 index b5dabde2fc..0000000000 --- a/libs/unimrcp/plugins/mrcp-pocketsphinx/src/pocketsphinx_properties.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2008-2010 Arsen Chaloyan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id: pocketsphinx_properties.c 1743 2010-07-12 08:04:46Z achaloyan $ - */ - -#include -#include -#include "pocketsphinx_properties.h" -#include "apt_log.h" - -static const apr_xml_elem* pocketsphinx_document_load(const char *file_path, apr_pool_t *pool) -{ - apr_xml_parser *parser = NULL; - apr_xml_doc *doc = NULL; - const apr_xml_elem *root; - apr_file_t *fd = NULL; - apr_status_t rv; - - apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Open PocketSphinx Config File [%s]",file_path); - rv = apr_file_open(&fd,file_path,APR_READ|APR_BINARY,0,pool); - if(rv != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open PocketSphinx Config File [%s]",file_path); - return FALSE; - } - - rv = apr_xml_parse_file(pool,&parser,&doc,fd,2000); - if(rv != APR_SUCCESS) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Parse PocketSphinx Config File [%s]",file_path); - apr_file_close(fd); - return FALSE; - } - - root = doc->root; - if(!root || strcasecmp(root->name,"pocketsphinx") != 0) { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Document <%s>",root->name); - apr_file_close(fd); - return FALSE; - } - - apr_file_close(fd); - return root; -} - -static apt_bool_t sensitivity_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool) -{ - const apr_xml_attr *attr; - for(attr = elem->attr; attr; attr = attr->next) { - if(strcasecmp(attr->name,"level") == 0) { - properties->sensitivity_level = atol(attr->value); - } - else if(strcasecmp(attr->name,"activity-timeout") == 0) { - properties->activity_timeout = atol(attr->value); - } - else if(strcasecmp(attr->name,"inactivity-timeout") == 0) { - properties->inactivity_timeout = atol(attr->value); - } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name); - } - } - return TRUE; -} - -static apt_bool_t timer_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool) -{ - const apr_xml_attr *attr; - for(attr = elem->attr; attr; attr = attr->next) { - if(strcasecmp(attr->name,"noinput-timeout") == 0) { - properties->no_input_timeout = atol(attr->value); - } - else if(strcasecmp(attr->name,"recognition-timeout") == 0) { - properties->recognition_timeout = atol(attr->value); - } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name); - } - } - return TRUE; -} - -static apt_bool_t model_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool) -{ - const apr_xml_attr *attr; - for(attr = elem->attr; attr; attr = attr->next) { - if(strcasecmp(attr->name,"dir") == 0) { - properties->data_dir = apr_pstrdup(pool,attr->value); - } - else if(strcasecmp(attr->name,"narrowband") == 0) { - properties->model_8k = apr_pstrdup(pool,attr->value); - } - else if(strcasecmp(attr->name,"wideband") == 0) { - properties->model_16k = apr_pstrdup(pool,attr->value); - } - else if(strcasecmp(attr->name,"dictionary") == 0) { - properties->dictionary = apr_pstrdup(pool,attr->value); - } - else if(strcasecmp(attr->name,"preferred") == 0) { - if(strcasecmp(attr->value,"narrowband") == 0) { - properties->preferred_model = POCKETSPHINX_MODEL_NARROWBAND; - } - else if(strcasecmp(attr->value,"wideband") == 0) { - properties->preferred_model = POCKETSPHINX_MODEL_WIDEBAND; - } - } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name); - } - } - return TRUE; -} - -static apt_bool_t save_waveform_properties_load(pocketsphinx_properties_t *properties, const apr_xml_elem *elem, apr_pool_t *pool) -{ - const apr_xml_attr *attr; - for(attr = elem->attr; attr; attr = attr->next) { - if(strcasecmp(attr->name,"dir") == 0) { - properties->save_waveform_dir = apr_pstrdup(pool,attr->value); - } - else if(strcasecmp(attr->name,"enable") == 0) { - properties->save_waveform = atoi(attr->value); - } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Attribute <%s>",attr->name); - } - } - return TRUE; -} - -apt_bool_t pocketsphinx_properties_load(pocketsphinx_properties_t *properties, - const char *file_path, - const apt_dir_layout_t *dir_layout, - apr_pool_t *pool) -{ - const apr_xml_elem *elem; - const apr_xml_elem *root; - char *path = NULL; - - /* reset or set default properties */ - properties->data_dir = NULL; - properties->dictionary = NULL; - properties->model_8k = NULL; - properties->model_16k = NULL; - properties->preferred_model = POCKETSPHINX_MODEL_NARROWBAND; - - properties->no_input_timeout = 10000; - properties->recognition_timeout = 15000; - properties->partial_result_timeout = 100; - - properties->save_waveform = TRUE; - properties->save_waveform_dir = NULL; - - root = pocketsphinx_document_load(file_path,pool); - if(root) { - for(elem = root->first_child; elem; elem = elem->next) { - if(strcasecmp(elem->name,"sensitivity") == 0) { - sensitivity_properties_load(properties,elem,pool); - } - else if(strcasecmp(elem->name,"timers") == 0) { - timer_properties_load(properties,elem,pool); - } - else if(strcasecmp(elem->name,"model") == 0) { - model_properties_load(properties,elem,pool); - } - else if(strcasecmp(elem->name,"save-waveform") == 0) { - save_waveform_properties_load(properties,elem,pool); - } - else { - apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unknown Element <%s>",elem->name); - } - } - } - - /* verify loaded properties */ - if(!properties->data_dir || *properties->data_dir == '\0') { - properties->data_dir = dir_layout->data_dir_path; - } - if(!properties->save_waveform_dir || *properties->save_waveform_dir == '\0') { - properties->save_waveform_dir = dir_layout->data_dir_path; - } - - if(!properties->dictionary) { - properties->dictionary = "default.dic"; - } - if(!properties->model_8k) { - properties->model_8k = "communicator"; - } - if(!properties->model_16k) { - properties->model_16k = "wsj1"; - } - - if(apr_filepath_merge(&path,properties->data_dir,properties->dictionary,0,pool) == APR_SUCCESS) { - properties->dictionary = path; - } - if(apr_filepath_merge(&path,properties->data_dir,properties->model_8k,0,pool) == APR_SUCCESS) { - properties->model_8k = path; - } - if(apr_filepath_merge(&path,properties->data_dir,properties->model_16k,0,pool) == APR_SUCCESS) { - properties->model_16k = path; - } - - return TRUE; -} diff --git a/libs/unimrcp/plugins/mrcp-recorder/Makefile.am b/libs/unimrcp/plugins/mrcp-recorder/Makefile.am index 68ec9e4e7c..fe49710588 100644 --- a/libs/unimrcp/plugins/mrcp-recorder/Makefile.am +++ b/libs/unimrcp/plugins/mrcp-recorder/Makefile.am @@ -1,16 +1,8 @@ -MAINTAINERCLEANFILES = Makefile.in - -AM_CPPFLAGS = -Iinclude \ - -I$(top_srcdir)/libs/mrcp-engine/include \ - -I$(top_srcdir)/libs/mrcp/include \ - -I$(top_srcdir)/libs/mrcp/message/include \ - -I$(top_srcdir)/libs/mrcp/control/include \ - -I$(top_srcdir)/libs/mrcp/resources/include \ - -I$(top_srcdir)/libs/mpf/include \ - -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = $(UNIMRCP_PLUGIN_INCLUDES) plugin_LTLIBRARIES = mrcprecorder.la mrcprecorder_la_SOURCES = src/mrcp_recorder_engine.c -mrcprecorder_la_LDFLAGS = -module $(PLUGIN_LT_VERSION) +mrcprecorder_la_LDFLAGS = $(UNIMRCP_PLUGIN_OPTS) + +include $(top_srcdir)/build/rules/uniplugin.am diff --git a/libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj b/libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj new file mode 100644 index 0000000000..53710b658f --- /dev/null +++ b/libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj @@ -0,0 +1,123 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2} + mrcprecorder + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + include;%(AdditionalIncludeDirectories) + + + + + include;%(AdditionalIncludeDirectories) + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + ProgramDatabase + + + + + X64 + + + include;%(AdditionalIncludeDirectories) + + + + + + + + {843425be-9a9a-44f4-a4e3-4b57d6abd53c} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj.filters b/libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj.filters new file mode 100644 index 0000000000..6fe96d5625 --- /dev/null +++ b/libs/unimrcp/plugins/mrcp-recorder/mrcprecorder.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {b1d2c804-b3bb-4413-8d11-7ff67d4e874c} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/plugins/mrcp-recorder/src/mrcp_recorder_engine.c b/libs/unimrcp/plugins/mrcp-recorder/src/mrcp_recorder_engine.c index f24de00f04..785be23efb 100644 --- a/libs/unimrcp/plugins/mrcp-recorder/src/mrcp_recorder_engine.c +++ b/libs/unimrcp/plugins/mrcp-recorder/src/mrcp_recorder_engine.c @@ -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: mrcp_recorder_engine.c 1706 2010-05-23 14:11:11Z achaloyan $ + * $Id: mrcp_recorder_engine.c 2193 2014-10-08 03:44:33Z achaloyan@gmail.com $ */ /* @@ -77,7 +77,8 @@ static const mpf_audio_stream_vtable_t audio_stream_vtable = { NULL, recorder_stream_open, recorder_stream_close, - recorder_stream_write + recorder_stream_write, + NULL }; /** Declaration of recorder channel */ @@ -205,14 +206,22 @@ static apt_bool_t recorder_channel_close(mrcp_engine_channel_t *channel) /** Open file to record */ static apt_bool_t recorder_file_open(recorder_channel_t *recorder_channel, mrcp_message_t *request) { + char *file_path; + char *file_name; mrcp_engine_channel_t *channel = recorder_channel->channel; const apt_dir_layout_t *dir_layout = channel->engine->dir_layout; const mpf_codec_descriptor_t *descriptor = mrcp_engine_sink_stream_codec_get(channel); - char *file_name = apr_psprintf(channel->pool,"rec-%dkHz-%s-%"MRCP_REQUEST_ID_FMT".pcm", - descriptor ? descriptor->sampling_rate/1000 : 8, + + if(!descriptor) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Codec Descriptor "APT_SIDRES_FMT, MRCP_MESSAGE_SIDRES(request)); + return FALSE; + } + + file_name = apr_psprintf(channel->pool,"rec-%dkHz-%s-%"MRCP_REQUEST_ID_FMT".pcm", + descriptor->sampling_rate/1000, request->channel_id.session_id.buf, request->start_line.request_id); - char *file_path = apt_datadir_filepath_get(dir_layout,file_name,channel->pool); + file_path = apt_vardir_filepath_get(dir_layout,file_name,channel->pool); if(!file_path) { return FALSE; } @@ -222,8 +231,10 @@ static apt_bool_t recorder_file_open(recorder_channel_t *recorder_channel, mrcp_ recorder_channel->audio_out = NULL; } + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Utterance Output File [%s] for Writing",file_path); recorder_channel->audio_out = fopen(file_path,"wb"); if(!recorder_channel->audio_out) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Utterance Output File [%s] for Writing",file_path); return FALSE; } diff --git a/libs/unimrcp/tests/apttest/Makefile.am b/libs/unimrcp/tests/apttest/Makefile.am index bf8783d5b0..205207400a 100644 --- a/libs/unimrcp/tests/apttest/Makefile.am +++ b/libs/unimrcp/tests/apttest/Makefile.am @@ -1,11 +1,11 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_PROGRAMS = apttest apttest_LDADD = $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) + $(UNIMRCP_APR_LIBS) apttest_SOURCES = src/main.c \ src/task_suite.c \ src/consumer_task_suite.c \ diff --git a/libs/unimrcp/tests/apttest/apttest.2008.vcproj b/libs/unimrcp/tests/apttest/apttest.2008.vcproj deleted file mode 100644 index 0bdaaf1f43..0000000000 --- a/libs/unimrcp/tests/apttest/apttest.2008.vcproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/tests/apttest/apttest.vcxproj b/libs/unimrcp/tests/apttest/apttest.vcxproj new file mode 100644 index 0000000000..90a1e85163 --- /dev/null +++ b/libs/unimrcp/tests/apttest/apttest.vcxproj @@ -0,0 +1,127 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15} + apttest + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + ProgramDatabase + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + X64 + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + + + {13deeca0-bdd4-4744-a1a2-8eb0a44df3d2} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/apttest/apttest.vcxproj.filters b/libs/unimrcp/tests/apttest/apttest.vcxproj.filters new file mode 100644 index 0000000000..eba965070c --- /dev/null +++ b/libs/unimrcp/tests/apttest/apttest.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/apttest/src/consumer_task_suite.c b/libs/unimrcp/tests/apttest/src/consumer_task_suite.c index 2c1ecdc7d5..74f8197b05 100644 --- a/libs/unimrcp/tests/apttest/src/consumer_task_suite.c +++ b/libs/unimrcp/tests/apttest/src/consumer_task_suite.c @@ -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: consumer_task_suite.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: consumer_task_suite.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/tests/apttest/src/main.c b/libs/unimrcp/tests/apttest/src/main.c index 1d30c9de32..772f7f0003 100644 --- a/libs/unimrcp/tests/apttest/src/main.c +++ b/libs/unimrcp/tests/apttest/src/main.c @@ -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.c 1539 2010-02-22 19:49:33Z achaloyan $ + * $Id: main.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/apttest/src/multipart_suite.c b/libs/unimrcp/tests/apttest/src/multipart_suite.c index 6c162c5145..74a9c29b1a 100644 --- a/libs/unimrcp/tests/apttest/src/multipart_suite.c +++ b/libs/unimrcp/tests/apttest/src/multipart_suite.c @@ -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: multipart_suite.c 1673 2010-04-28 20:45:47Z achaloyan $ + * $Id: multipart_suite.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/apttest/src/task_suite.c b/libs/unimrcp/tests/apttest/src/task_suite.c index c1873c0aa3..e42f14e598 100644 --- a/libs/unimrcp/tests/apttest/src/task_suite.c +++ b/libs/unimrcp/tests/apttest/src/task_suite.c @@ -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: task_suite.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: task_suite.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/mpftest/Makefile.am b/libs/unimrcp/tests/mpftest/Makefile.am index b4bf49da64..0a032d121b 100644 --- a/libs/unimrcp/tests/mpftest/Makefile.am +++ b/libs/unimrcp/tests/mpftest/Makefile.am @@ -2,11 +2,11 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/mpf/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_PROGRAMS = mpftest mpftest_LDADD = $(top_builddir)/libs/mpf/libmpf.la \ $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) + $(UNIMRCP_APR_LIBS) mpftest_SOURCES = src/main.c \ src/mpf_suite.c diff --git a/libs/unimrcp/tests/mpftest/mpftest.2008.vcproj b/libs/unimrcp/tests/mpftest/mpftest.2008.vcproj deleted file mode 100644 index 4c013cdb36..0000000000 --- a/libs/unimrcp/tests/mpftest/mpftest.2008.vcproj +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/tests/mpftest/mpftest.vcxproj b/libs/unimrcp/tests/mpftest/mpftest.vcxproj new file mode 100644 index 0000000000..134792797c --- /dev/null +++ b/libs/unimrcp/tests/mpftest/mpftest.vcxproj @@ -0,0 +1,125 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DCF01B1C-5268-44F3-9130-D647FABFB663} + mpftest + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;ws2_32.lib;winmm.lib;%(AdditionalDependencies) + + + + + mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;ws2_32.lib;winmm.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + ProgramDatabase + + + mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;ws2_32.lib;winmm.lib;%(AdditionalDependencies) + + + + + X64 + + + mpf.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;ws2_32.lib;winmm.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + {b5a00bfa-6083-4fae-a097-71642d6473b5} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/mpftest/mpftest.vcxproj.filters b/libs/unimrcp/tests/mpftest/mpftest.vcxproj.filters new file mode 100644 index 0000000000..dbe64db07d --- /dev/null +++ b/libs/unimrcp/tests/mpftest/mpftest.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/mpftest/src/main.c b/libs/unimrcp/tests/mpftest/src/main.c index 7fd5440525..7e61aa19e7 100644 --- a/libs/unimrcp/tests/mpftest/src/main.c +++ b/libs/unimrcp/tests/mpftest/src/main.c @@ -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.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: main.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/mpftest/src/mpf_suite.c b/libs/unimrcp/tests/mpftest/src/mpf_suite.c index 0a0d3a2f07..a18e3319ae 100644 --- a/libs/unimrcp/tests/mpftest/src/mpf_suite.c +++ b/libs/unimrcp/tests/mpftest/src/mpf_suite.c @@ -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,23 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: mpf_suite.c 1700 2010-05-21 18:56:06Z achaloyan $ + * $Id: mpf_suite.c 2214 2014-11-06 03:05:51Z achaloyan@gmail.com $ */ #include #include "apt_test_suite.h" +#include "apt_pool.h" +#include "apt_consumer_task.h" +#include "apt_dir_layout.h" +#include "apt_log.h" #include "mpf_engine.h" #include "mpf_rtp_termination_factory.h" #include "mpf_file_termination_factory.h" #include "mpf_audio_file_descriptor.h" #include "mpf_rtp_descriptor.h" -#include "apt_pool.h" -#include "apt_consumer_task.h" -#include "apt_log.h" +#include "mpf_codec_manager.h" typedef struct mpf_suite_session_t mpf_suite_session_t; -typedef struct mpf_suite_engine_t mpf_suite_engine_t; - +typedef struct mpf_suite_agent_t mpf_suite_agent_t; /** Test suite session */ struct mpf_suite_session_t { @@ -39,16 +40,16 @@ struct mpf_suite_session_t { /** Media context associated with the session */ mpf_context_t *context; /** The first termination in the context */ - mpf_termination_t *termination1; + mpf_termination_t *file_termination; /** The second termination in the context */ - mpf_termination_t *termination2; - /** RTP or file termination mode */ - apt_bool_t rtp_mode; + mpf_termination_t *rtp_termination; }; -/** Test suite engine */ -struct mpf_suite_engine_t { - /** The main task of the test engine, which sends messages to MPF engine and +/** Test suite agent */ +struct mpf_suite_agent_t { + /** Directory layout */ + apt_dir_layout_t *dir_layout; + /** The main task of the test agent, which sends messages to MPF engine and * processes responses and events sent back from MPF engine */ apt_consumer_task_t *consumer_task; /** MPF engine */ @@ -57,6 +58,15 @@ struct mpf_suite_engine_t { mpf_termination_factory_t *rtp_termination_factory; /** File termination factory */ mpf_termination_factory_t *file_termination_factory; + /* Configuration of RTP termination factory */ + mpf_rtp_config_t *rtp_config; + /* RTP stream settings */ + mpf_rtp_settings_t *rtp_settings; + + /** RTP receiver -> File */ + mpf_suite_session_t *rx_session; + /** File -> RTP transmitter */ + mpf_suite_session_t *tx_session; /** Wait object, which is signalled to indicate shutdown */ apr_thread_cond_t *wait_object; @@ -70,10 +80,12 @@ static void mpf_suite_on_start_complete(apt_task_t *task); static void mpf_suite_on_terminate_complete(apt_task_t *task); static apt_bool_t mpf_suite_task_msg_process(apt_task_t *task, apt_task_msg_t *msg); -static mpf_audio_file_descriptor_t* mpf_file_reader_descriptor_create(mpf_suite_session_t *session); -static mpf_audio_file_descriptor_t* mpf_file_writer_descriptor_create(mpf_suite_session_t *session); -static mpf_rtp_stream_descriptor_t* mpf_rtp_local_descriptor_create(mpf_suite_session_t *session); -static mpf_rtp_stream_descriptor_t* mpf_rtp_remote_descriptor_create(mpf_suite_session_t *session); +static mpf_audio_file_descriptor_t* mpf_file_reader_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session); +static mpf_audio_file_descriptor_t* mpf_file_writer_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session); +static mpf_rtp_stream_descriptor_t* mpf_rtp_rx_local_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session); +static mpf_rtp_stream_descriptor_t* mpf_rtp_rx_remote_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session); +static mpf_rtp_stream_descriptor_t* mpf_rtp_tx_local_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session); +static mpf_rtp_stream_descriptor_t* mpf_rtp_tx_remote_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session); /** Create MPF test suite */ @@ -86,44 +98,68 @@ apt_test_suite_t* mpf_suite_create(apr_pool_t *pool) /** Run MPF test suite */ static apt_bool_t mpf_test_run(apt_test_suite_t *suite, int argc, const char * const *argv) { - mpf_suite_engine_t *suite_engine; + mpf_suite_agent_t *agent; mpf_codec_manager_t *codec_manager; - mpf_rtp_config_t *config; + mpf_rtp_config_t *rtp_config; + mpf_rtp_settings_t *rtp_settings; mpf_engine_t *engine; apt_task_t *task; apt_task_vtable_t *vtable; apt_task_msg_pool_t *msg_pool; - suite_engine = apr_palloc(suite->pool,sizeof(mpf_suite_engine_t)); + agent = apr_palloc(suite->pool,sizeof(mpf_suite_agent_t)); + agent->dir_layout = apt_default_dir_layout_create(NULL,suite->pool); engine = mpf_engine_create("MPF-Engine",suite->pool); if(!engine) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create MPF Engine"); return FALSE; } - codec_manager = mpf_engine_codec_manager_create(suite->pool); - if(codec_manager) { - mpf_engine_codec_manager_register(engine,codec_manager); - } - suite_engine->engine = engine; - config = mpf_rtp_config_alloc(suite->pool); - apt_string_set(&config->ip,"127.0.0.1"); - config->rtp_port_min = 5000; - config->rtp_port_min = 6000; - suite_engine->rtp_termination_factory = mpf_rtp_termination_factory_create(config,suite->pool); - suite_engine->file_termination_factory = mpf_file_termination_factory_create(suite->pool); + codec_manager = mpf_engine_codec_manager_create(suite->pool); + if(!codec_manager) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Codec Manager"); + return FALSE; + } + + mpf_engine_codec_manager_register(engine,codec_manager); + agent->engine = engine; + + rtp_config = mpf_rtp_config_alloc(suite->pool); + apt_string_set(&rtp_config->ip,"127.0.0.1"); + rtp_config->rtp_port_min = 5000; + rtp_config->rtp_port_max = 6000; + + agent->rtp_config = rtp_config; + + rtp_settings = mpf_rtp_settings_alloc(suite->pool); + rtp_settings->ptime = 20; + rtp_settings->jb_config.adaptive = 1; + rtp_settings->jb_config.time_skew_detection = 1; + rtp_settings->jb_config.min_playout_delay = 0; + rtp_settings->jb_config.initial_playout_delay = 50; + rtp_settings->jb_config.max_playout_delay = 800; + mpf_codec_manager_codec_list_load(codec_manager,&rtp_settings->codec_list,"PCMU",suite->pool); + + agent->rtp_settings = rtp_settings; + + agent->rtp_termination_factory = mpf_rtp_termination_factory_create(rtp_config,suite->pool); + agent->file_termination_factory = mpf_file_termination_factory_create(suite->pool); + + agent->rx_session = NULL; + agent->tx_session = NULL; msg_pool = apt_task_msg_pool_create_dynamic(sizeof(mpf_message_t),suite->pool); apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create Consumer Task"); - suite_engine->consumer_task = apt_consumer_task_create(suite_engine,msg_pool,suite->pool); - if(!suite_engine->consumer_task) { + agent->consumer_task = apt_consumer_task_create(agent,msg_pool,suite->pool); + if(!agent->consumer_task) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Consumer Task"); return FALSE; } - task = apt_consumer_task_base_get(suite_engine->consumer_task); + task = apt_consumer_task_base_get(agent->consumer_task); + apt_task_name_set(task,"MPF-Tester"); vtable = apt_task_vtable_get(task); if(vtable) { vtable->process_msg = mpf_suite_task_msg_process; @@ -133,88 +169,147 @@ static apt_bool_t mpf_test_run(apt_test_suite_t *suite, int argc, const char * c apt_task_add(task,mpf_task_get(engine)); - apr_thread_mutex_create(&suite_engine->wait_object_mutex,APR_THREAD_MUTEX_UNNESTED,suite->pool); - apr_thread_cond_create(&suite_engine->wait_object,suite->pool); + apr_thread_mutex_create(&agent->wait_object_mutex,APR_THREAD_MUTEX_UNNESTED,suite->pool); + apr_thread_cond_create(&agent->wait_object,suite->pool); - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Start Task"); if(apt_task_start(task) == FALSE) { apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Task"); apt_task_destroy(task); return FALSE; } - apr_thread_mutex_lock(suite_engine->wait_object_mutex); - apr_thread_cond_wait(suite_engine->wait_object,suite_engine->wait_object_mutex); - apr_thread_mutex_unlock(suite_engine->wait_object_mutex); + apr_thread_mutex_lock(agent->wait_object_mutex); + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Wait for Task to Complete"); + apr_thread_cond_wait(agent->wait_object,agent->wait_object_mutex); + apr_thread_mutex_unlock(agent->wait_object_mutex); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Task [wait till complete]"); apt_task_terminate(task,TRUE); apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy Task"); apt_task_destroy(task); - apr_thread_cond_destroy(suite_engine->wait_object); - apr_thread_mutex_destroy(suite_engine->wait_object_mutex); + apr_thread_cond_destroy(agent->wait_object); + apr_thread_mutex_destroy(agent->wait_object_mutex); return TRUE; } +static mpf_suite_session_t* mpf_suite_rx_session_create(const mpf_suite_agent_t *agent) +{ + mpf_task_msg_t *task_msg = NULL; + void *descriptor; + apr_pool_t *pool; + mpf_suite_session_t *session; + + pool = apt_pool_create(); + session = apr_palloc(pool,sizeof(mpf_suite_session_t)); + session->pool = pool; + session->context = NULL; + session->file_termination = NULL; + session->rtp_termination = NULL; + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create MPF Context [Rx]"); + session->context = mpf_engine_context_create(agent->engine,NULL,session,2,pool); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Termination [RTP Rx]"); + session->rtp_termination = mpf_termination_create(agent->rtp_termination_factory,session,session->pool); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Termination [RTP Rx]"); + descriptor = mpf_rtp_rx_local_descriptor_create(agent,session); + mpf_engine_termination_message_add( + agent->engine, + MPF_ADD_TERMINATION,session->context,session->rtp_termination,descriptor, + &task_msg); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Termination [File Writer]"); + session->file_termination = mpf_termination_create(agent->file_termination_factory,session,session->pool); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Termination [File Writer]"); + descriptor = mpf_file_writer_descriptor_create(agent,session); + mpf_engine_termination_message_add( + agent->engine, + MPF_ADD_TERMINATION,session->context,session->file_termination,descriptor, + &task_msg); + + mpf_engine_message_send(agent->engine,&task_msg); + return session; +} + +static mpf_suite_session_t* mpf_suite_tx_session_create(const mpf_suite_agent_t *agent) +{ + mpf_task_msg_t *task_msg = NULL; + void *descriptor; + apr_pool_t *pool; + mpf_suite_session_t *session; + + pool = apt_pool_create(); + session = apr_palloc(pool,sizeof(mpf_suite_session_t)); + session->pool = pool; + session->context = NULL; + session->file_termination = NULL; + session->rtp_termination = NULL; + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create MPF Context [Tx]"); + session->context = mpf_engine_context_create(agent->engine,NULL,session,2,pool); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Termination [File Reader]"); + session->file_termination = mpf_termination_create(agent->file_termination_factory,session,session->pool); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Termination [File Reader]"); + descriptor = mpf_file_reader_descriptor_create(agent,session); + mpf_engine_termination_message_add( + agent->engine, + MPF_ADD_TERMINATION,session->context,session->file_termination,descriptor, + &task_msg); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Termination [RTP Tx]"); + session->rtp_termination = mpf_termination_create(agent->rtp_termination_factory,session,session->pool); + + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Termination [RTP Tx]"); + descriptor = mpf_rtp_tx_local_descriptor_create(agent,session); + mpf_engine_termination_message_add( + agent->engine, + MPF_ADD_TERMINATION,session->context,session->rtp_termination,descriptor, + &task_msg); + + mpf_engine_message_send(agent->engine,&task_msg); + return session; +} + +static void mpf_suite_session_destroy(mpf_suite_agent_t *agent, mpf_suite_session_t* session) +{ + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Destroy MPF Context"); + mpf_engine_context_destroy(session->context); + session->context = NULL; + + if(agent->rx_session == session) { + agent->rx_session = NULL; + } + else if(agent->tx_session == session) { + agent->tx_session = NULL; + } + + apr_pool_destroy(session->pool); + + if(!agent->tx_session && !agent->rx_session) { + apr_thread_mutex_lock(agent->wait_object_mutex); + apr_thread_cond_signal(agent->wait_object); + apr_thread_mutex_unlock(agent->wait_object_mutex); + } +} + /** Start execution of MPF test suite scenario */ static void mpf_suite_on_start_complete(apt_task_t *task) { - mpf_suite_session_t *session; - apt_task_t *consumer_task; - mpf_suite_engine_t *suite_engine; - mpf_task_msg_t *task_msg = NULL; - void *descriptor; - apr_pool_t *pool = NULL; + apt_consumer_task_t *consumer_task; + mpf_suite_agent_t *agent; consumer_task = apt_task_object_get(task); - suite_engine = apt_task_object_get(consumer_task); + agent = apt_consumer_task_object_get(consumer_task); apt_log(APT_LOG_MARK,APT_PRIO_INFO,"On MPF Suite Start"); - pool = apt_pool_create(); - session = apr_palloc(pool,sizeof(mpf_suite_session_t)); - session->pool = pool; - session->context = NULL; - session->termination1 = NULL; - session->termination2 = NULL; - session->rtp_mode = TRUE; - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create MPF Context"); - session->context = mpf_engine_context_create(suite_engine->engine,NULL,session,2,pool); - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Termination [1]"); - session->termination1 = mpf_termination_create(suite_engine->file_termination_factory,session,session->pool); - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Termination [1]"); - descriptor = mpf_file_reader_descriptor_create(session); - mpf_engine_termination_message_add( - suite_engine->engine, - MPF_ADD_TERMINATION,session->context,session->termination1,descriptor, - &task_msg); - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create Termination [2]"); - if(session->rtp_mode == TRUE) { - session->termination2 = mpf_termination_create(suite_engine->rtp_termination_factory,session,session->pool); - } - else { - session->termination2 = mpf_termination_create(suite_engine->file_termination_factory,session,session->pool); - } - - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Add Termination [2]"); - descriptor = NULL; - if(session->rtp_mode == TRUE) { - descriptor = mpf_rtp_local_descriptor_create(session); - } - else { - descriptor = mpf_file_writer_descriptor_create(session); - } - - mpf_engine_termination_message_add( - suite_engine->engine, - MPF_ADD_TERMINATION,session->context,session->termination2,descriptor, - &task_msg); - - mpf_engine_message_send(suite_engine->engine,&task_msg); + agent->rx_session = mpf_suite_rx_session_create(agent); + agent->tx_session = mpf_suite_tx_session_create(agent); } /** Execution of MPF test suite scenario is terminated */ @@ -224,7 +319,7 @@ static void mpf_suite_on_terminate_complete(apt_task_t *task) } /** Process MPF response */ -static apt_bool_t mpf_suite_response_process(mpf_suite_engine_t *suite_engine, const mpf_message_t *mpf_message) +static apt_bool_t mpf_suite_response_process(mpf_suite_agent_t *agent, const mpf_message_t *mpf_message) { mpf_task_msg_t *task_msg = NULL; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process MPF Response"); @@ -233,12 +328,31 @@ static apt_bool_t mpf_suite_response_process(mpf_suite_engine_t *suite_engine, c if(mpf_message->termination) { mpf_suite_session_t *session; session = mpf_termination_object_get(mpf_message->termination); - if(session->termination2 == mpf_message->termination && session->rtp_mode == TRUE) { - void *descriptor = mpf_rtp_remote_descriptor_create(session); - mpf_engine_termination_message_add( - suite_engine->engine, - MPF_MODIFY_TERMINATION,session->context,session->termination2,descriptor, - &task_msg); + if(session->rtp_termination == mpf_message->termination) { + mpf_rtp_stream_descriptor_t *descriptor = NULL; + if(session == agent->rx_session) { + descriptor = mpf_rtp_rx_remote_descriptor_create(agent,session); + } + if(session == agent->tx_session) { + descriptor = mpf_rtp_tx_remote_descriptor_create(agent,session); + } + + if(descriptor) { + mpf_engine_termination_message_add( + agent->engine, + MPF_MODIFY_TERMINATION,session->context,session->rtp_termination,descriptor, + &task_msg); + } + + mpf_engine_assoc_message_add( + agent->engine, + MPF_ADD_ASSOCIATION,session->context,session->file_termination,session->rtp_termination, + &task_msg); + + mpf_engine_topology_message_add( + agent->engine, + MPF_APPLY_TOPOLOGY,session->context, + &task_msg); } } } @@ -247,52 +361,52 @@ static apt_bool_t mpf_suite_response_process(mpf_suite_engine_t *suite_engine, c if(mpf_message->termination) { mpf_suite_session_t *session; session = mpf_termination_object_get(mpf_message->termination); - if(session->termination1 == mpf_message->termination) { - session->termination1 = NULL; + if(session->file_termination == mpf_message->termination) { + session->file_termination = NULL; } - if(session->termination2 == mpf_message->termination) { - session->termination2 = NULL; + else if(session->rtp_termination == mpf_message->termination) { + session->rtp_termination = NULL; } mpf_termination_destroy(mpf_message->termination); - if(!session->termination1 && !session->termination2) { - mpf_engine_context_destroy(session->context); - session->context = NULL; - apr_pool_destroy(session->pool); - - apr_thread_mutex_lock(suite_engine->wait_object_mutex); - apr_thread_cond_signal(suite_engine->wait_object); - apr_thread_mutex_unlock(suite_engine->wait_object_mutex); + if(!session->file_termination && !session->rtp_termination) { + mpf_suite_session_destroy(agent,session); } } } - return mpf_engine_message_send(suite_engine->engine,&task_msg); + return mpf_engine_message_send(agent->engine,&task_msg); } /** Process MPF event */ -static apt_bool_t mpf_suite_event_process(mpf_suite_engine_t *suite_engine, const mpf_message_t *mpf_message) +static apt_bool_t mpf_suite_event_process(mpf_suite_agent_t *agent, const mpf_message_t *mpf_message) { mpf_task_msg_t *task_msg = NULL; mpf_suite_session_t *session; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process MPF Event"); if(mpf_message->termination) { session = mpf_termination_object_get(mpf_message->termination); - if(session->termination1) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Subtract Termination [1]"); + /* first destroy existing topology */ + mpf_engine_topology_message_add( + agent->engine, + MPF_DESTROY_TOPOLOGY,session->context, + &task_msg); + + if(session->file_termination) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Subtract Termination [File]"); mpf_engine_termination_message_add( - suite_engine->engine, - MPF_SUBTRACT_TERMINATION,session->context,session->termination1,NULL, + agent->engine, + MPF_SUBTRACT_TERMINATION,session->context,session->file_termination,NULL, &task_msg); } - if(session->termination2) { - apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Subtract Termination [2]"); + if(session->rtp_termination) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Subtract Termination [RTP]"); mpf_engine_termination_message_add( - suite_engine->engine, - MPF_SUBTRACT_TERMINATION,session->context,session->termination2,NULL, + agent->engine, + MPF_SUBTRACT_TERMINATION,session->context,session->rtp_termination,NULL, &task_msg); } } - return mpf_engine_message_send(suite_engine->engine,&task_msg); + return mpf_engine_message_send(agent->engine,&task_msg); } /** Process task messages */ @@ -300,82 +414,158 @@ static apt_bool_t mpf_suite_task_msg_process(apt_task_t *task, apt_task_msg_t *m { apr_size_t i; const mpf_message_t *mpf_message; - apt_task_t *consumer_task = apt_task_object_get(task); - mpf_suite_engine_t *suite_engine = apt_task_object_get(consumer_task); + apt_consumer_task_t *consumer_task = apt_task_object_get(task); + mpf_suite_agent_t *agent = apt_consumer_task_object_get(consumer_task); const mpf_message_container_t *container = (const mpf_message_container_t*) msg->data; for(i=0; icount; i++) { mpf_message = &container->messages[i]; if(mpf_message->message_type == MPF_MESSAGE_TYPE_RESPONSE) { - mpf_suite_response_process(suite_engine,mpf_message); + mpf_suite_response_process(agent,mpf_message); } else { - mpf_suite_event_process(suite_engine,mpf_message); + mpf_suite_event_process(agent,mpf_message); } } return TRUE; } -/** Create sample file reader descriptor */ -static mpf_audio_file_descriptor_t* mpf_file_reader_descriptor_create(mpf_suite_session_t *session) +/** Create file reader descriptor */ +static mpf_audio_file_descriptor_t* mpf_file_reader_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session) { + const char *file_path = apt_datadir_filepath_get(agent->dir_layout,"demo-8kHz.pcm",session->pool); mpf_audio_file_descriptor_t *descriptor = apr_palloc(session->pool,sizeof(mpf_audio_file_descriptor_t)); descriptor->mask = FILE_READER; - descriptor->read_handle = fopen("demo.pcm","rb"); + descriptor->read_handle = NULL; descriptor->write_handle = NULL; descriptor->codec_descriptor = mpf_codec_lpcm_descriptor_create(8000,1,session->pool); + if(file_path) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open File [%s] for Reading",file_path); + descriptor->read_handle = fopen(file_path,"rb"); + if(!descriptor->read_handle) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open File [%s]",file_path); + } + } return descriptor; } -/** Create sample file writer descriptor */ -static mpf_audio_file_descriptor_t* mpf_file_writer_descriptor_create(mpf_suite_session_t *session) +/** Create file writer descriptor */ +static mpf_audio_file_descriptor_t* mpf_file_writer_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session) { + const char *file_path = apt_vardir_filepath_get(agent->dir_layout,"output-8kHz.pcm",session->pool); mpf_audio_file_descriptor_t *descriptor = apr_palloc(session->pool,sizeof(mpf_audio_file_descriptor_t)); descriptor->mask = FILE_WRITER; - descriptor->max_write_size = 500000; /* 500Kb */ - descriptor->write_handle = fopen("demo_out.pcm","wb"); + descriptor->max_write_size = 500000; /* ~500Kb */ + descriptor->write_handle = NULL; descriptor->read_handle = NULL; descriptor->codec_descriptor = mpf_codec_lpcm_descriptor_create(8000,1,session->pool); + if(file_path) { + apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open File [%s] for Writing",file_path); + descriptor->write_handle = fopen(file_path,"wb"); + if(!descriptor->write_handle) { + apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open File [%s] for Writing",file_path); + } + } return descriptor; } -/** Create sample RTP local descriptor */ -static mpf_rtp_stream_descriptor_t* mpf_rtp_local_descriptor_create(mpf_suite_session_t *session) +/** Create RTP rx local descriptor */ +static mpf_rtp_stream_descriptor_t* mpf_rtp_rx_local_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session) { - mpf_rtp_stream_descriptor_t *descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_stream_descriptor_t)); - mpf_rtp_stream_descriptor_init(descriptor); - descriptor->local = apr_palloc(session->pool,sizeof(mpf_rtp_media_descriptor_t)); - mpf_rtp_media_descriptor_init(descriptor->local); - descriptor->local->direction = STREAM_DIRECTION_NONE; - apt_string_set(&descriptor->local->ip,"127.0.0.1"); - descriptor->local->port = 5000; - return descriptor; + mpf_rtp_media_descriptor_t *media_descriptor; + mpf_rtp_stream_descriptor_t *stream_descriptor; + + media_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_media_descriptor_t)); + mpf_rtp_media_descriptor_init(media_descriptor); + media_descriptor->state = MPF_MEDIA_ENABLED; + media_descriptor->direction = STREAM_DIRECTION_RECEIVE; + apt_string_set(&media_descriptor->ip,"127.0.0.1"); + media_descriptor->port = 5000; + + stream_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_stream_descriptor_t)); + mpf_rtp_stream_descriptor_init(stream_descriptor); + stream_descriptor->local = media_descriptor; + stream_descriptor->settings = agent->rtp_settings; + return stream_descriptor; } -/** Create sample RTP remote descriptor */ -static mpf_rtp_stream_descriptor_t* mpf_rtp_remote_descriptor_create(mpf_suite_session_t *session) +/** Create RTP rx remote descriptor */ +static mpf_rtp_stream_descriptor_t* mpf_rtp_rx_remote_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session) { mpf_codec_list_t *codec_list; mpf_codec_descriptor_t *codec_descriptor; - mpf_rtp_stream_descriptor_t *descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_stream_descriptor_t)); - mpf_rtp_stream_descriptor_init(descriptor); - descriptor->remote = apr_palloc(session->pool,sizeof(mpf_rtp_media_descriptor_t)); - mpf_rtp_media_descriptor_init(descriptor->remote); - descriptor->remote->direction = STREAM_DIRECTION_DUPLEX; - apt_string_set(&descriptor->remote->ip,"127.0.0.1"); - descriptor->remote->port = 5002; - codec_list = &descriptor->remote->codec_list; - mpf_codec_list_init(codec_list,2,session->pool); + mpf_rtp_media_descriptor_t *media_descriptor; + mpf_rtp_stream_descriptor_t *stream_descriptor; + + media_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_media_descriptor_t)); + mpf_rtp_media_descriptor_init(media_descriptor); + media_descriptor->state = MPF_MEDIA_ENABLED; + media_descriptor->direction = STREAM_DIRECTION_SEND; + apt_string_set(&media_descriptor->ip,"127.0.0.1"); + media_descriptor->port = 5002; + codec_list = &media_descriptor->codec_list; + mpf_codec_list_init(codec_list,1,session->pool); codec_descriptor = mpf_codec_list_add(codec_list); if(codec_descriptor) { codec_descriptor->payload_type = 0; - } - codec_descriptor = mpf_codec_list_add(codec_list); - if(codec_descriptor) { - codec_descriptor->payload_type = 96; apt_string_set(&codec_descriptor->name,"PCMU"); - codec_descriptor->sampling_rate = 16000; + codec_descriptor->sampling_rate = 8000; codec_descriptor->channel_count = 1; } - return descriptor; + stream_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_stream_descriptor_t)); + mpf_rtp_stream_descriptor_init(stream_descriptor); + stream_descriptor->remote = media_descriptor; + stream_descriptor->settings = agent->rtp_settings; + return stream_descriptor; +} + +/** Create RTP tx local descriptor */ +static mpf_rtp_stream_descriptor_t* mpf_rtp_tx_local_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session) +{ + mpf_rtp_media_descriptor_t *media_descriptor; + mpf_rtp_stream_descriptor_t *stream_descriptor; + + media_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_media_descriptor_t)); + mpf_rtp_media_descriptor_init(media_descriptor); + media_descriptor->state = MPF_MEDIA_ENABLED; + media_descriptor->direction = STREAM_DIRECTION_SEND; + apt_string_set(&media_descriptor->ip,"127.0.0.1"); + media_descriptor->port = 5002; + + stream_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_stream_descriptor_t)); + mpf_rtp_stream_descriptor_init(stream_descriptor); + stream_descriptor->local = media_descriptor; + stream_descriptor->settings = agent->rtp_settings; + return stream_descriptor; +} + +/** Create RTP tx remote descriptor */ +static mpf_rtp_stream_descriptor_t* mpf_rtp_tx_remote_descriptor_create(const mpf_suite_agent_t *agent, const mpf_suite_session_t *session) +{ + mpf_codec_list_t *codec_list; + mpf_codec_descriptor_t *codec_descriptor; + mpf_rtp_media_descriptor_t *media_descriptor; + mpf_rtp_stream_descriptor_t *stream_descriptor; + + media_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_media_descriptor_t)); + mpf_rtp_media_descriptor_init(media_descriptor); + media_descriptor->state = MPF_MEDIA_ENABLED; + media_descriptor->direction = STREAM_DIRECTION_RECEIVE; + apt_string_set(&media_descriptor->ip,"127.0.0.1"); + media_descriptor->port = 5000; + codec_list = &media_descriptor->codec_list; + mpf_codec_list_init(codec_list,1,session->pool); + codec_descriptor = mpf_codec_list_add(codec_list); + if(codec_descriptor) { + codec_descriptor->payload_type = 0; + apt_string_set(&codec_descriptor->name,"PCMU"); + codec_descriptor->sampling_rate = 8000; + codec_descriptor->channel_count = 1; + } + + stream_descriptor = apr_palloc(session->pool,sizeof(mpf_rtp_stream_descriptor_t)); + mpf_rtp_stream_descriptor_init(stream_descriptor); + stream_descriptor->remote = media_descriptor; + stream_descriptor->settings = agent->rtp_settings; + return stream_descriptor; } diff --git a/libs/unimrcp/tests/mrcptest/Makefile.am b/libs/unimrcp/tests/mrcptest/Makefile.am index 83e91b413f..02bba67955 100644 --- a/libs/unimrcp/tests/mrcptest/Makefile.am +++ b/libs/unimrcp/tests/mrcptest/Makefile.am @@ -5,12 +5,12 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/mrcp/include \ -I$(top_srcdir)/libs/mrcp/control/include \ -I$(top_srcdir)/libs/mrcp/resources/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_PROGRAMS = mrcptest mrcptest_LDADD = $(top_builddir)/libs/mrcp/libmrcp.la \ $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) + $(UNIMRCP_APR_LIBS) mrcptest_SOURCES = src/main.c \ src/parse_gen_suite.c \ src/set_get_suite.c \ diff --git a/libs/unimrcp/tests/mrcptest/mrcptest.2008.vcproj b/libs/unimrcp/tests/mrcptest/mrcptest.2008.vcproj deleted file mode 100644 index afe6314f0b..0000000000 --- a/libs/unimrcp/tests/mrcptest/mrcptest.2008.vcproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/tests/mrcptest/mrcptest.vcxproj b/libs/unimrcp/tests/mrcptest/mrcptest.vcxproj new file mode 100644 index 0000000000..7e3309b489 --- /dev/null +++ b/libs/unimrcp/tests/mrcptest/mrcptest.vcxproj @@ -0,0 +1,127 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3CA97077-6210-4362-998A-D15A35EEAA08} + mrcptest + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + mrcp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + mrcp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + ProgramDatabase + + + mrcp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + X64 + + + mrcp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + + + {1c320193-46a6-4b34-9c56-8ab584fc1b56} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/mrcptest/mrcptest.vcxproj.filters b/libs/unimrcp/tests/mrcptest/mrcptest.vcxproj.filters new file mode 100644 index 0000000000..b0435c5f24 --- /dev/null +++ b/libs/unimrcp/tests/mrcptest/mrcptest.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/mrcptest/src/main.c b/libs/unimrcp/tests/mrcptest/src/main.c index dbb16c14c3..dd12d22177 100644 --- a/libs/unimrcp/tests/mrcptest/src/main.c +++ b/libs/unimrcp/tests/mrcptest/src/main.c @@ -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.c 1637 2010-04-03 18:29:24Z achaloyan $ + * $Id: main.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/mrcptest/src/parse_gen_suite.c b/libs/unimrcp/tests/mrcptest/src/parse_gen_suite.c index c04de89d30..13b32915f9 100644 --- a/libs/unimrcp/tests/mrcptest/src/parse_gen_suite.c +++ b/libs/unimrcp/tests/mrcptest/src/parse_gen_suite.c @@ -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: parse_gen_suite.c 1667 2010-04-25 07:04:31Z achaloyan $ + * $Id: parse_gen_suite.c 2215 2014-11-06 03:07:23Z achaloyan@gmail.com $ */ #include @@ -167,11 +167,12 @@ static apt_bool_t test_dir_process(apt_test_suite_t *suite, mrcp_resource_factor rv = apr_dir_read(&finfo,APR_FINFO_DIRENT,dir); if(rv == APR_SUCCESS) { if(finfo.filetype == APR_REG && finfo.name) { + int ch; char *file_path; - apr_filepath_merge(&file_path,dir_name,finfo.name,0,suite->pool); + apr_filepath_merge(&file_path,dir_name,finfo.name,APR_FILEPATH_NATIVE,suite->pool); test_file_process(suite,factory,version,file_path); printf("\nPress ENTER to continue\n"); - getchar(); + do {ch = getchar(); } while ((ch != '\n') && (ch != EOF)); } } } diff --git a/libs/unimrcp/tests/mrcptest/src/set_get_suite.c b/libs/unimrcp/tests/mrcptest/src/set_get_suite.c index b214b26c7b..f7ac1cfcef 100644 --- a/libs/unimrcp/tests/mrcptest/src/set_get_suite.c +++ b/libs/unimrcp/tests/mrcptest/src/set_get_suite.c @@ -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: set_get_suite.c 1637 2010-04-03 18:29:24Z achaloyan $ + * $Id: set_get_suite.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/mrcptest/src/transparent_set_get_suite.c b/libs/unimrcp/tests/mrcptest/src/transparent_set_get_suite.c index da1e3eda2d..19ab6e4206 100644 --- a/libs/unimrcp/tests/mrcptest/src/transparent_set_get_suite.c +++ b/libs/unimrcp/tests/mrcptest/src/transparent_set_get_suite.c @@ -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: transparent_set_get_suite.c 1637 2010-04-03 18:29:24Z achaloyan $ + * $Id: transparent_set_get_suite.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/rtsptest/Makefile.am b/libs/unimrcp/tests/rtsptest/Makefile.am index 7dbc6432d8..0a6f82f231 100644 --- a/libs/unimrcp/tests/rtsptest/Makefile.am +++ b/libs/unimrcp/tests/rtsptest/Makefile.am @@ -2,11 +2,11 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/libs/uni-rtsp/include \ -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) + $(UNIMRCP_APR_INCLUDES) noinst_PROGRAMS = rtsptest rtsptest_LDADD = $(top_builddir)/libs/uni-rtsp/libunirtsp.la \ $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) + $(UNIMRCP_APR_LIBS) rtsptest_SOURCES = src/main.c \ src/parse_gen_suite.c diff --git a/libs/unimrcp/tests/rtsptest/rtsptest.2008.vcproj b/libs/unimrcp/tests/rtsptest/rtsptest.2008.vcproj deleted file mode 100644 index fa93e0b998..0000000000 --- a/libs/unimrcp/tests/rtsptest/rtsptest.2008.vcproj +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/libs/mrcp-client/mrcpclient.2012.vcxproj b/libs/unimrcp/tests/rtsptest/rtsptest.vcxproj similarity index 51% rename from libs/unimrcp/libs/mrcp-client/mrcpclient.2012.vcxproj rename to libs/unimrcp/tests/rtsptest/rtsptest.vcxproj index 3426eb6381..6adedfe996 100644 --- a/libs/unimrcp/libs/mrcp-client/mrcpclient.2012.vcxproj +++ b/libs/unimrcp/tests/rtsptest/rtsptest.vcxproj @@ -1,126 +1,125 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mrcpclient - {72782932-37CC-46AE-8C7F-9A7B1A6EE108} - mrcpclient - Win32Proj - - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - StaticLibrary - Unicode - true - v110 - - - StaticLibrary - Unicode - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - $(PlatformName)\$(Configuration)\ - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - ProgramDatabase - - - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - X64 - - - APT_STATIC_LIB;MPF_STATIC_LIB;MRCP_STATIC_LIB;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335} + rtsptest + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + unirtsp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + unirtsp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + ProgramDatabase + + + unirtsp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + X64 + + + unirtsp.lib;aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + + {504b3154-7a4f-459d-9877-b951021c3f1f} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/rtsptest/rtsptest.vcxproj.filters b/libs/unimrcp/tests/rtsptest/rtsptest.vcxproj.filters new file mode 100644 index 0000000000..62dd2c5691 --- /dev/null +++ b/libs/unimrcp/tests/rtsptest/rtsptest.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/rtsptest/src/main.c b/libs/unimrcp/tests/rtsptest/src/main.c index 45c03287aa..df5bad58fd 100644 --- a/libs/unimrcp/tests/rtsptest/src/main.c +++ b/libs/unimrcp/tests/rtsptest/src/main.c @@ -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.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: main.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include "apt_test_suite.h" diff --git a/libs/unimrcp/tests/rtsptest/src/parse_gen_suite.c b/libs/unimrcp/tests/rtsptest/src/parse_gen_suite.c index cae9d8f9ba..b860770dbd 100644 --- a/libs/unimrcp/tests/rtsptest/src/parse_gen_suite.c +++ b/libs/unimrcp/tests/rtsptest/src/parse_gen_suite.c @@ -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: parse_gen_suite.c 1667 2010-04-25 07:04:31Z achaloyan $ + * $Id: parse_gen_suite.c 2240 2014-11-13 01:18:47Z achaloyan@gmail.com $ */ #include @@ -131,11 +131,12 @@ static apt_bool_t test_dir_process(apt_test_suite_t *suite) rv = apr_dir_read(&finfo,APR_FINFO_DIRENT,dir); if(rv == APR_SUCCESS) { if(finfo.filetype == APR_REG && finfo.name) { + int ch; char *file_path; - apr_filepath_merge(&file_path,dir_name,finfo.name,0,suite->pool); + apr_filepath_merge(&file_path,dir_name,finfo.name,APR_FILEPATH_NATIVE,suite->pool); test_file_process(suite,file_path); printf("\nPress ENTER to continue\n"); - getchar(); + do {ch = getchar(); } while ((ch != '\n') && (ch != EOF)); } } } diff --git a/libs/unimrcp/tests/strtablegen/Makefile.am b/libs/unimrcp/tests/strtablegen/Makefile.am index ab25346b74..5ffb011dc7 100644 --- a/libs/unimrcp/tests/strtablegen/Makefile.am +++ b/libs/unimrcp/tests/strtablegen/Makefile.am @@ -1,9 +1,9 @@ MAINTAINERCLEANFILES = Makefile.in -AM_CPPFLAGS = -I$(top_srcdir)/libs/apr-toolkit/include \ - $(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES) +AM_CPPFLAGS = -I$(top_srcdir)/libs/apr-toolkit/include \ + $(UNIMRCP_APR_INCLUDES) noinst_PROGRAMS = strtablegen strtablegen_LDADD = $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \ - $(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS) + $(UNIMRCP_APR_LIBS) strtablegen_SOURCES = src/main.c diff --git a/libs/unimrcp/tests/strtablegen/src/main.c b/libs/unimrcp/tests/strtablegen/src/main.c index 55eba8896c..ef82abc796 100644 --- a/libs/unimrcp/tests/strtablegen/src/main.c +++ b/libs/unimrcp/tests/strtablegen/src/main.c @@ -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.c 1474 2010-02-07 20:51:47Z achaloyan $ + * $Id: main.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ */ #include diff --git a/libs/unimrcp/tests/strtablegen/strtablegen.2008.vcproj b/libs/unimrcp/tests/strtablegen/strtablegen.2008.vcproj deleted file mode 100644 index a1d32e4384..0000000000 --- a/libs/unimrcp/tests/strtablegen/strtablegen.2008.vcproj +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/unimrcp/tests/strtablegen/strtablegen.vcxproj b/libs/unimrcp/tests/strtablegen/strtablegen.vcxproj new file mode 100644 index 0000000000..5cd5add13d --- /dev/null +++ b/libs/unimrcp/tests/strtablegen/strtablegen.vcxproj @@ -0,0 +1,124 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872} + strtablegen + + + + Application + + + Application + + + Application + + + Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + X64 + + + ProgramDatabase + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + + + + + X64 + + + aprtoolkit.lib;libaprutil-1.lib;libapr-1.lib;%(AdditionalDependencies) + UseLinkTimeCodeGeneration + + + + + + + + {13deeca0-bdd4-4744-a1a2-8eb0a44df3d2} + false + + + + + + \ No newline at end of file diff --git a/libs/unimrcp/tests/strtablegen/strtablegen.vcxproj.filters b/libs/unimrcp/tests/strtablegen/strtablegen.vcxproj.filters new file mode 100644 index 0000000000..3efc5f63ae --- /dev/null +++ b/libs/unimrcp/tests/strtablegen/strtablegen.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + src + + + \ No newline at end of file diff --git a/libs/unimrcp/unimrcp-2010.sln b/libs/unimrcp/unimrcp-2010.sln new file mode 100644 index 0000000000..957d126a62 --- /dev/null +++ b/libs/unimrcp/unimrcp-2010.sln @@ -0,0 +1,358 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{5377DC3A-DB96-4819-8AAF-2A75F3A69119}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{493A1DB9-6E7C-48C7-93B5-F75C3C25B9DF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "platforms", "platforms", "{8E282AE2-038C-49FE-AC67-BC9615AFD800}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{09BABD45-8F30-4F99-B8B8-8DD78F6804DB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AC4356E8-48A1-4D2D-AFB1-11CF30B974CD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{62083CC3-13BF-49EA-BFE8-4C9337C0D82C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "conf", "conf", "{9155EBB8-E7DD-49AE-A86A-7B90B9F09888}" + ProjectSection(SolutionItems) = preProject + conf\logger.xml = conf\logger.xml + conf\unimrcpclient.xml = conf\unimrcpclient.xml + conf\unimrcpclient.xsd = conf\unimrcpclient.xsd + conf\unimrcpserver.xml = conf\unimrcpserver.xml + conf\unimrcpserver.xsd = conf\unimrcpserver.xsd + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client-profiles", "client-profiles", "{F2D6C1AF-0C05-4695-84AF-15A2F92F9899}" + ProjectSection(SolutionItems) = preProject + conf\client-profiles\lumenvox.xml = conf\client-profiles\lumenvox.xml + conf\client-profiles\nuance.xml = conf\client-profiles\nuance.xml + conf\client-profiles\unimrcp.xml = conf\client-profiles\unimrcp.xml + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpserver", "platforms\unimrcp-server\unimrcpserver.vcxproj", "{592CF22D-3F8F-4A77-A174-130D77B7623B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aprtoolkit", "libs\apr-toolkit\aprtoolkit.vcxproj", "{13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpf", "libs\mpf\mpf.vcxproj", "{B5A00BFA-6083-4FAE-A097-71642D6473B5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcp", "libs\mrcp\mrcp.vcxproj", "{1C320193-46A6-4B34-9C56-8AB584FC1B56}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsignaling", "libs\mrcp-signaling\mrcpsignaling.vcxproj", "{12A49562-BAB9-43A3-A21D-15B60BBB4C31}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpserver", "libs\mrcp-server\mrcpserver.vcxproj", "{18B1F35A-10F8-4287-9B37-2D10501B0B38}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunimrcpserver", "platforms\libunimrcp-server\libunimrcpserver.vcxproj", "{C98AF157-352E-4737-BD30-A24E2647F5AE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsofiasip", "modules\mrcp-sofiasip\mrcpsofiasip.vcxproj", "{746F3632-5BB2-4570-9453-31D6D58A7D8E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpclient", "libs\mrcp-client\mrcpclient.vcxproj", "{72782932-37CC-46AE-8C7F-9A7B1A6EE108}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunimrcpclient", "platforms\libunimrcp-client\libunimrcpclient.vcxproj", "{EE157390-1E85-416C-946E-620E32C9AD33}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpclient", "platforms\unimrcp-client\unimrcpclient.vcxproj", "{57FAF32E-49FD-491F-895D-132D0D5EFE0A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpv2transport", "libs\mrcpv2-transport\mrcpv2transport.vcxproj", "{A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpengine", "libs\mrcp-engine\mrcpengine.vcxproj", "{843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demosynth", "plugins\demo-synth\demosynth.vcxproj", "{92BFA534-C419-4EB2-AAA3-510653F38F08}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demorecog", "plugins\demo-recog\demorecog.vcxproj", "{B495B6D9-AF84-479D-B30A-313C16EF8BFD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strtablegen", "tests\strtablegen\strtablegen.vcxproj", "{79EF9F1D-E211-4ED1-91D2-FC935AB3A872}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "apttest", "tests\apttest\apttest.vcxproj", "{429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpftest", "tests\mpftest\mpftest.vcxproj", "{DCF01B1C-5268-44F3-9130-D647FABFB663}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcptest", "tests\mrcptest\mrcptest.vcxproj", "{3CA97077-6210-4362-998A-D15A35EEAA08}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unirtsp", "libs\uni-rtsp\unirtsp.vcxproj", "{504B3154-7A4F-459D-9877-B951021C3F1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rtsptest", "tests\rtsptest\rtsptest.vcxproj", "{17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpunirtsp", "modules\mrcp-unirtsp\mrcpunirtsp.vcxproj", "{DEB01ACB-D65F-4A62-AED9-58C1054499E9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prepare", "build\tools\prepare.vcxproj", "{01D63BF5-7798-4746-852A-4B45229BB735}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpservice", "build\tools\unimrcpservice.vcxproj", "{4714EF49-BFD5-4B22-95F7-95A07F1EAC25}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asrclient", "platforms\asr-client\asrclient.vcxproj", "{6B83AC6D-01CE-4E1C-81CE-02AD8116C684}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libasrclient", "platforms\libasr-client\libasrclient.vcxproj", "{272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "umc", "platforms\umc\umc.vcxproj", "{CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcprecorder", "plugins\mrcp-recorder\mrcprecorder.vcxproj", "{5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demoverifier", "plugins\demo-verifier\demoverifier.vcxproj", "{F7563CAD-5C95-46E5-89B7-0953C6C6E746}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Debug|Win32.ActiveCfg = Debug|Win32 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Debug|Win32.Build.0 = Debug|Win32 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Debug|x64.ActiveCfg = Debug|x64 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Debug|x64.Build.0 = Debug|x64 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Release|Win32.ActiveCfg = Release|Win32 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Release|Win32.Build.0 = Release|Win32 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Release|x64.ActiveCfg = Release|x64 + {592CF22D-3F8F-4A77-A174-130D77B7623B}.Release|x64.Build.0 = Release|x64 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|Win32.ActiveCfg = Debug|Win32 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|Win32.Build.0 = Debug|Win32 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|x64.ActiveCfg = Debug|x64 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|x64.Build.0 = Debug|x64 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|Win32.ActiveCfg = Release|Win32 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|Win32.Build.0 = Release|Win32 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|x64.ActiveCfg = Release|x64 + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|x64.Build.0 = Release|x64 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|Win32.ActiveCfg = Debug|Win32 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|Win32.Build.0 = Debug|Win32 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|x64.ActiveCfg = Debug|x64 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|x64.Build.0 = Debug|x64 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|Win32.ActiveCfg = Release|Win32 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|Win32.Build.0 = Release|Win32 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|x64.ActiveCfg = Release|x64 + {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|x64.Build.0 = Release|x64 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|Win32.ActiveCfg = Debug|Win32 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|Win32.Build.0 = Debug|Win32 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|x64.ActiveCfg = Debug|x64 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|x64.Build.0 = Debug|x64 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|Win32.ActiveCfg = Release|Win32 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|Win32.Build.0 = Release|Win32 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|x64.ActiveCfg = Release|x64 + {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|x64.Build.0 = Release|x64 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|Win32.ActiveCfg = Debug|Win32 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|Win32.Build.0 = Debug|Win32 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|x64.ActiveCfg = Debug|x64 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|x64.Build.0 = Debug|x64 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|Win32.ActiveCfg = Release|Win32 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|Win32.Build.0 = Release|Win32 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|x64.ActiveCfg = Release|x64 + {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|x64.Build.0 = Release|x64 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Debug|Win32.ActiveCfg = Debug|Win32 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Debug|Win32.Build.0 = Debug|Win32 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Debug|x64.ActiveCfg = Debug|x64 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Debug|x64.Build.0 = Debug|x64 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Release|Win32.ActiveCfg = Release|Win32 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Release|Win32.Build.0 = Release|Win32 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Release|x64.ActiveCfg = Release|x64 + {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Release|x64.Build.0 = Release|x64 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Debug|Win32.ActiveCfg = Debug|Win32 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Debug|Win32.Build.0 = Debug|Win32 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Debug|x64.ActiveCfg = Debug|x64 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Debug|x64.Build.0 = Debug|x64 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Release|Win32.ActiveCfg = Release|Win32 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Release|Win32.Build.0 = Release|Win32 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Release|x64.ActiveCfg = Release|x64 + {C98AF157-352E-4737-BD30-A24E2647F5AE}.Release|x64.Build.0 = Release|x64 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|Win32.Build.0 = Debug|Win32 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|x64.ActiveCfg = Debug|x64 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|x64.Build.0 = Debug|x64 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|Win32.ActiveCfg = Release|Win32 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|Win32.Build.0 = Release|Win32 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|x64.ActiveCfg = Release|x64 + {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|x64.Build.0 = Release|x64 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|Win32.ActiveCfg = Debug|Win32 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|Win32.Build.0 = Debug|Win32 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|x64.ActiveCfg = Debug|x64 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|x64.Build.0 = Debug|x64 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|Win32.ActiveCfg = Release|Win32 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|Win32.Build.0 = Release|Win32 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|x64.ActiveCfg = Release|x64 + {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|x64.Build.0 = Release|x64 + {EE157390-1E85-416C-946E-620E32C9AD33}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE157390-1E85-416C-946E-620E32C9AD33}.Debug|Win32.Build.0 = Debug|Win32 + {EE157390-1E85-416C-946E-620E32C9AD33}.Debug|x64.ActiveCfg = Debug|x64 + {EE157390-1E85-416C-946E-620E32C9AD33}.Debug|x64.Build.0 = Debug|x64 + {EE157390-1E85-416C-946E-620E32C9AD33}.Release|Win32.ActiveCfg = Release|Win32 + {EE157390-1E85-416C-946E-620E32C9AD33}.Release|Win32.Build.0 = Release|Win32 + {EE157390-1E85-416C-946E-620E32C9AD33}.Release|x64.ActiveCfg = Release|x64 + {EE157390-1E85-416C-946E-620E32C9AD33}.Release|x64.Build.0 = Release|x64 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Debug|Win32.ActiveCfg = Debug|Win32 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Debug|Win32.Build.0 = Debug|Win32 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Debug|x64.ActiveCfg = Debug|x64 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Debug|x64.Build.0 = Debug|x64 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Release|Win32.ActiveCfg = Release|Win32 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Release|Win32.Build.0 = Release|Win32 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Release|x64.ActiveCfg = Release|x64 + {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Release|x64.Build.0 = Release|x64 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|Win32.ActiveCfg = Debug|Win32 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|Win32.Build.0 = Debug|Win32 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|x64.ActiveCfg = Debug|x64 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|x64.Build.0 = Debug|x64 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|Win32.ActiveCfg = Release|Win32 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|Win32.Build.0 = Release|Win32 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|x64.ActiveCfg = Release|x64 + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|x64.Build.0 = Release|x64 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Debug|Win32.ActiveCfg = Debug|Win32 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Debug|Win32.Build.0 = Debug|Win32 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Debug|x64.ActiveCfg = Debug|x64 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Debug|x64.Build.0 = Debug|x64 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Release|Win32.ActiveCfg = Release|Win32 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Release|Win32.Build.0 = Release|Win32 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Release|x64.ActiveCfg = Release|x64 + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Release|x64.Build.0 = Release|x64 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Debug|Win32.ActiveCfg = Debug|Win32 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Debug|Win32.Build.0 = Debug|Win32 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Debug|x64.ActiveCfg = Debug|x64 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Debug|x64.Build.0 = Debug|x64 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Release|Win32.ActiveCfg = Release|Win32 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Release|Win32.Build.0 = Release|Win32 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Release|x64.ActiveCfg = Release|x64 + {92BFA534-C419-4EB2-AAA3-510653F38F08}.Release|x64.Build.0 = Release|x64 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Debug|Win32.ActiveCfg = Debug|Win32 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Debug|Win32.Build.0 = Debug|Win32 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Debug|x64.ActiveCfg = Debug|x64 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Debug|x64.Build.0 = Debug|x64 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Release|Win32.ActiveCfg = Release|Win32 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Release|Win32.Build.0 = Release|Win32 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Release|x64.ActiveCfg = Release|x64 + {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Release|x64.Build.0 = Release|x64 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Debug|Win32.ActiveCfg = Debug|Win32 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Debug|Win32.Build.0 = Debug|Win32 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Debug|x64.ActiveCfg = Debug|x64 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Debug|x64.Build.0 = Debug|x64 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Release|Win32.ActiveCfg = Release|Win32 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Release|Win32.Build.0 = Release|Win32 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Release|x64.ActiveCfg = Release|x64 + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Release|x64.Build.0 = Release|x64 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Debug|Win32.ActiveCfg = Debug|Win32 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Debug|Win32.Build.0 = Debug|Win32 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Debug|x64.ActiveCfg = Debug|x64 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Debug|x64.Build.0 = Debug|x64 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Release|Win32.ActiveCfg = Release|Win32 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Release|Win32.Build.0 = Release|Win32 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Release|x64.ActiveCfg = Release|x64 + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Release|x64.Build.0 = Release|x64 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Debug|Win32.ActiveCfg = Debug|Win32 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Debug|Win32.Build.0 = Debug|Win32 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Debug|x64.ActiveCfg = Debug|x64 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Debug|x64.Build.0 = Debug|x64 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Release|Win32.ActiveCfg = Release|Win32 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Release|Win32.Build.0 = Release|Win32 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Release|x64.ActiveCfg = Release|x64 + {DCF01B1C-5268-44F3-9130-D647FABFB663}.Release|x64.Build.0 = Release|x64 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Debug|Win32.ActiveCfg = Debug|Win32 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Debug|Win32.Build.0 = Debug|Win32 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Debug|x64.ActiveCfg = Debug|x64 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Debug|x64.Build.0 = Debug|x64 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Release|Win32.ActiveCfg = Release|Win32 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Release|Win32.Build.0 = Release|Win32 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Release|x64.ActiveCfg = Release|x64 + {3CA97077-6210-4362-998A-D15A35EEAA08}.Release|x64.Build.0 = Release|x64 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|Win32.ActiveCfg = Debug|Win32 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|Win32.Build.0 = Debug|Win32 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|x64.ActiveCfg = Debug|x64 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|x64.Build.0 = Debug|x64 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|Win32.ActiveCfg = Release|Win32 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|Win32.Build.0 = Release|Win32 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|x64.ActiveCfg = Release|x64 + {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|x64.Build.0 = Release|x64 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Debug|Win32.ActiveCfg = Debug|Win32 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Debug|Win32.Build.0 = Debug|Win32 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Debug|x64.ActiveCfg = Debug|x64 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Debug|x64.Build.0 = Debug|x64 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Release|Win32.ActiveCfg = Release|Win32 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Release|Win32.Build.0 = Release|Win32 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Release|x64.ActiveCfg = Release|x64 + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Release|x64.Build.0 = Release|x64 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|Win32.ActiveCfg = Debug|Win32 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|Win32.Build.0 = Debug|Win32 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|x64.ActiveCfg = Debug|x64 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|x64.Build.0 = Debug|x64 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|Win32.ActiveCfg = Release|Win32 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|Win32.Build.0 = Release|Win32 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|x64.ActiveCfg = Release|x64 + {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|x64.Build.0 = Release|x64 + {01D63BF5-7798-4746-852A-4B45229BB735}.Debug|Win32.ActiveCfg = Debug|Win32 + {01D63BF5-7798-4746-852A-4B45229BB735}.Debug|x64.ActiveCfg = Debug|x64 + {01D63BF5-7798-4746-852A-4B45229BB735}.Release|Win32.ActiveCfg = Release|Win32 + {01D63BF5-7798-4746-852A-4B45229BB735}.Release|x64.ActiveCfg = Release|x64 + {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Debug|Win32.ActiveCfg = Debug|Win32 + {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Debug|x64.ActiveCfg = Debug|x64 + {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Release|Win32.ActiveCfg = Release|Win32 + {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Release|x64.ActiveCfg = Release|x64 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|Win32.ActiveCfg = Debug|Win32 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|Win32.Build.0 = Debug|Win32 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|x64.ActiveCfg = Debug|x64 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|x64.Build.0 = Debug|x64 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Release|Win32.ActiveCfg = Release|Win32 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Release|Win32.Build.0 = Release|Win32 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Release|x64.ActiveCfg = Release|x64 + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Release|x64.Build.0 = Release|x64 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Debug|Win32.ActiveCfg = Debug|Win32 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Debug|Win32.Build.0 = Debug|Win32 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Debug|x64.ActiveCfg = Debug|x64 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Debug|x64.Build.0 = Debug|x64 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Release|Win32.ActiveCfg = Release|Win32 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Release|Win32.Build.0 = Release|Win32 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Release|x64.ActiveCfg = Release|x64 + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3}.Release|x64.Build.0 = Release|x64 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Debug|Win32.ActiveCfg = Debug|Win32 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Debug|Win32.Build.0 = Debug|Win32 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Debug|x64.ActiveCfg = Debug|x64 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Debug|x64.Build.0 = Debug|x64 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Release|Win32.ActiveCfg = Release|Win32 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Release|Win32.Build.0 = Release|Win32 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Release|x64.ActiveCfg = Release|x64 + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894}.Release|x64.Build.0 = Release|x64 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Debug|Win32.ActiveCfg = Debug|Win32 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Debug|Win32.Build.0 = Debug|Win32 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Debug|x64.ActiveCfg = Debug|x64 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Debug|x64.Build.0 = Debug|x64 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|Win32.ActiveCfg = Release|Win32 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|Win32.Build.0 = Release|Win32 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|x64.ActiveCfg = Release|x64 + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|x64.Build.0 = Release|x64 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|Win32.ActiveCfg = Debug|Win32 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|Win32.Build.0 = Debug|Win32 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|x64.ActiveCfg = Debug|x64 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|x64.Build.0 = Debug|x64 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|Win32.ActiveCfg = Release|Win32 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|Win32.Build.0 = Release|Win32 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|x64.ActiveCfg = Release|x64 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {B5A00BFA-6083-4FAE-A097-71642D6473B5} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {18B1F35A-10F8-4287-9B37-2D10501B0B38} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {72782932-37CC-46AE-8C7F-9A7B1A6EE108} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {504B3154-7A4F-459D-9877-B951021C3F1F} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} + {746F3632-5BB2-4570-9453-31D6D58A7D8E} = {493A1DB9-6E7C-48C7-93B5-F75C3C25B9DF} + {DEB01ACB-D65F-4A62-AED9-58C1054499E9} = {493A1DB9-6E7C-48C7-93B5-F75C3C25B9DF} + {592CF22D-3F8F-4A77-A174-130D77B7623B} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {C98AF157-352E-4737-BD30-A24E2647F5AE} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {EE157390-1E85-416C-946E-620E32C9AD33} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {57FAF32E-49FD-491F-895D-132D0D5EFE0A} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {6B83AC6D-01CE-4E1C-81CE-02AD8116C684} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} + {92BFA534-C419-4EB2-AAA3-510653F38F08} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} + {B495B6D9-AF84-479D-B30A-313C16EF8BFD} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} + {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} + {F7563CAD-5C95-46E5-89B7-0953C6C6E746} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} + {79EF9F1D-E211-4ED1-91D2-FC935AB3A872} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} + {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} + {DCF01B1C-5268-44F3-9130-D647FABFB663} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} + {3CA97077-6210-4362-998A-D15A35EEAA08} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} + {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} + {01D63BF5-7798-4746-852A-4B45229BB735} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} + {4714EF49-BFD5-4B22-95F7-95A07F1EAC25} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} + {F2D6C1AF-0C05-4695-84AF-15A2F92F9899} = {9155EBB8-E7DD-49AE-A86A-7B90B9F09888} + EndGlobalSection +EndGlobal diff --git a/libs/unimrcp/unimrcp.2008.sln b/libs/unimrcp/unimrcp.2008.sln deleted file mode 100644 index 88aa31f6d4..0000000000 --- a/libs/unimrcp/unimrcp.2008.sln +++ /dev/null @@ -1,292 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{5377DC3A-DB96-4819-8AAF-2A75F3A69119}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{493A1DB9-6E7C-48C7-93B5-F75C3C25B9DF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "platforms", "platforms", "{8E282AE2-038C-49FE-AC67-BC9615AFD800}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{09BABD45-8F30-4F99-B8B8-8DD78F6804DB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AC4356E8-48A1-4D2D-AFB1-11CF30B974CD}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{62083CC3-13BF-49EA-BFE8-4C9337C0D82C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpserver", "platforms\unimrcp-server\unimrcpserver.2008.vcproj", "{592CF22D-3F8F-4A77-A174-130D77B7623B}" - ProjectSection(ProjectDependencies) = postProject - {C98AF157-352E-4737-BD30-A24E2647F5AE} = {C98AF157-352E-4737-BD30-A24E2647F5AE} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aprtoolkit", "libs\apr-toolkit\aprtoolkit.2008.vcproj", "{13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpf", "libs\mpf\mpf.2008.vcproj", "{B5A00BFA-6083-4FAE-A097-71642D6473B5}" - ProjectSection(ProjectDependencies) = postProject - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcp", "libs\mrcp\mrcp.2008.vcproj", "{1C320193-46A6-4B34-9C56-8AB584FC1B56}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsignaling", "libs\mrcp-signaling\mrcpsignaling.2008.vcproj", "{12A49562-BAB9-43A3-A21D-15B60BBB4C31}" - ProjectSection(ProjectDependencies) = postProject - {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {1C320193-46A6-4B34-9C56-8AB584FC1B56} - {B5A00BFA-6083-4FAE-A097-71642D6473B5} = {B5A00BFA-6083-4FAE-A097-71642D6473B5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpserver", "libs\mrcp-server\mrcpserver.2008.vcproj", "{18B1F35A-10F8-4287-9B37-2D10501B0B38}" - ProjectSection(ProjectDependencies) = postProject - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {12A49562-BAB9-43A3-A21D-15B60BBB4C31} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunimrcpserver", "platforms\libunimrcp-server\libunimrcpserver.2008.vcproj", "{C98AF157-352E-4737-BD30-A24E2647F5AE}" - ProjectSection(ProjectDependencies) = postProject - {746F3632-5BB2-4570-9453-31D6D58A7D8E} = {746F3632-5BB2-4570-9453-31D6D58A7D8E} - {18B1F35A-10F8-4287-9B37-2D10501B0B38} = {18B1F35A-10F8-4287-9B37-2D10501B0B38} - {DEB01ACB-D65F-4A62-AED9-58C1054499E9} = {DEB01ACB-D65F-4A62-AED9-58C1054499E9} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsofiasip", "modules\mrcp-sofiasip\mrcpsofiasip.2008.vcproj", "{746F3632-5BB2-4570-9453-31D6D58A7D8E}" - ProjectSection(ProjectDependencies) = postProject - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {12A49562-BAB9-43A3-A21D-15B60BBB4C31} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpclient", "libs\mrcp-client\mrcpclient.2008.vcproj", "{72782932-37CC-46AE-8C7F-9A7B1A6EE108}" - ProjectSection(ProjectDependencies) = postProject - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {12A49562-BAB9-43A3-A21D-15B60BBB4C31} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunimrcpclient", "platforms\libunimrcp-client\libunimrcpclient.2008.vcproj", "{EE157390-1E85-416C-946E-620E32C9AD33}" - ProjectSection(ProjectDependencies) = postProject - {72782932-37CC-46AE-8C7F-9A7B1A6EE108} = {72782932-37CC-46AE-8C7F-9A7B1A6EE108} - {746F3632-5BB2-4570-9453-31D6D58A7D8E} = {746F3632-5BB2-4570-9453-31D6D58A7D8E} - {DEB01ACB-D65F-4A62-AED9-58C1054499E9} = {DEB01ACB-D65F-4A62-AED9-58C1054499E9} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpclient", "platforms\unimrcp-client\unimrcpclient.2008.vcproj", "{57FAF32E-49FD-491F-895D-132D0D5EFE0A}" - ProjectSection(ProjectDependencies) = postProject - {EE157390-1E85-416C-946E-620E32C9AD33} = {EE157390-1E85-416C-946E-620E32C9AD33} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpv2transport", "libs\mrcpv2-transport\mrcpv2transport.2008.vcproj", "{A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}" - ProjectSection(ProjectDependencies) = postProject - {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {1C320193-46A6-4B34-9C56-8AB584FC1B56} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpengine", "libs\mrcp-engine\mrcpengine.2008.vcproj", "{843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}" - ProjectSection(ProjectDependencies) = postProject - {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {1C320193-46A6-4B34-9C56-8AB584FC1B56} - {B5A00BFA-6083-4FAE-A097-71642D6473B5} = {B5A00BFA-6083-4FAE-A097-71642D6473B5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demosynth", "plugins\demo-synth\demosynth.2008.vcproj", "{92BFA534-C419-4EB2-AAA3-510653F38F08}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demorecog", "plugins\demo-recog\demorecog.2008.vcproj", "{B495B6D9-AF84-479D-B30A-313C16EF8BFD}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strtablegen", "tests\strtablegen\strtablegen.2008.vcproj", "{79EF9F1D-E211-4ED1-91D2-FC935AB3A872}" - ProjectSection(ProjectDependencies) = postProject - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "apttest", "tests\apttest\apttest.2008.vcproj", "{429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}" - ProjectSection(ProjectDependencies) = postProject - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpftest", "tests\mpftest\mpftest.2008.vcproj", "{DCF01B1C-5268-44F3-9130-D647FABFB663}" - ProjectSection(ProjectDependencies) = postProject - {B5A00BFA-6083-4FAE-A097-71642D6473B5} = {B5A00BFA-6083-4FAE-A097-71642D6473B5} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcptest", "tests\mrcptest\mrcptest.2008.vcproj", "{3CA97077-6210-4362-998A-D15A35EEAA08}" - ProjectSection(ProjectDependencies) = postProject - {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {1C320193-46A6-4B34-9C56-8AB584FC1B56} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpcepstral", "plugins\mrcp-cepstral\mrcpcepstral.2008.vcproj", "{729EF28E-38C9-40DE-A138-87785F021411}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unirtsp", "libs\uni-rtsp\unirtsp.2008.vcproj", "{504B3154-7A4F-459D-9877-B951021C3F1F}" - ProjectSection(ProjectDependencies) = postProject - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rtsptest", "tests\rtsptest\rtsptest.2008.vcproj", "{17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}" - ProjectSection(ProjectDependencies) = postProject - {504B3154-7A4F-459D-9877-B951021C3F1F} = {504B3154-7A4F-459D-9877-B951021C3F1F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpunirtsp", "modules\mrcp-unirtsp\mrcpunirtsp.2008.vcproj", "{DEB01ACB-D65F-4A62-AED9-58C1054499E9}" - ProjectSection(ProjectDependencies) = postProject - {504B3154-7A4F-459D-9877-B951021C3F1F} = {504B3154-7A4F-459D-9877-B951021C3F1F} - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {12A49562-BAB9-43A3-A21D-15B60BBB4C31} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prepare", "build\tools\prepare.2008.vcproj", "{01D63BF5-7798-4746-852A-4B45229BB735}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpservice", "build\tools\unimrcpservice.2008.vcproj", "{4714EF49-BFD5-4B22-95F7-95A07F1EAC25}" - ProjectSection(ProjectDependencies) = postProject - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcppocketsphinx", "plugins\mrcp-pocketsphinx\mrcppocketsphinx.2008.vcproj", "{3C614AE8-B611-4D43-A9AF-1CAA440A9F69}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpflite", "plugins\mrcp-flite\mrcpflite.2008.vcproj", "{56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preparesphinx", "build\tools\preparesphinx.2008.vcproj", "{71D62A04-8EF6-4C6B-AC12-0C15A875E53A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {592CF22D-3F8F-4A77-A174-130D77B7623B}.Debug|Win32.ActiveCfg = Debug|Win32 - {592CF22D-3F8F-4A77-A174-130D77B7623B}.Debug|Win32.Build.0 = Debug|Win32 - {592CF22D-3F8F-4A77-A174-130D77B7623B}.Release|Win32.ActiveCfg = Release|Win32 - {592CF22D-3F8F-4A77-A174-130D77B7623B}.Release|Win32.Build.0 = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Debug|Win32.Build.0 = Debug|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|Win32.ActiveCfg = Release|Win32 - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}.Release|Win32.Build.0 = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|Win32.ActiveCfg = Debug|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Debug|Win32.Build.0 = Debug|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|Win32.ActiveCfg = Release|Win32 - {B5A00BFA-6083-4FAE-A097-71642D6473B5}.Release|Win32.Build.0 = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|Win32.ActiveCfg = Debug|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Debug|Win32.Build.0 = Debug|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|Win32.ActiveCfg = Release|Win32 - {1C320193-46A6-4B34-9C56-8AB584FC1B56}.Release|Win32.Build.0 = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|Win32.ActiveCfg = Debug|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Debug|Win32.Build.0 = Debug|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|Win32.ActiveCfg = Release|Win32 - {12A49562-BAB9-43A3-A21D-15B60BBB4C31}.Release|Win32.Build.0 = Release|Win32 - {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Debug|Win32.ActiveCfg = Debug|Win32 - {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Debug|Win32.Build.0 = Debug|Win32 - {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Release|Win32.ActiveCfg = Release|Win32 - {18B1F35A-10F8-4287-9B37-2D10501B0B38}.Release|Win32.Build.0 = Release|Win32 - {C98AF157-352E-4737-BD30-A24E2647F5AE}.Debug|Win32.ActiveCfg = Debug|Win32 - {C98AF157-352E-4737-BD30-A24E2647F5AE}.Debug|Win32.Build.0 = Debug|Win32 - {C98AF157-352E-4737-BD30-A24E2647F5AE}.Release|Win32.ActiveCfg = Release|Win32 - {C98AF157-352E-4737-BD30-A24E2647F5AE}.Release|Win32.Build.0 = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|Win32.ActiveCfg = Debug|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Debug|Win32.Build.0 = Debug|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|Win32.ActiveCfg = Release|Win32 - {746F3632-5BB2-4570-9453-31D6D58A7D8E}.Release|Win32.Build.0 = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|Win32.ActiveCfg = Debug|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Debug|Win32.Build.0 = Debug|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|Win32.ActiveCfg = Release|Win32 - {72782932-37CC-46AE-8C7F-9A7B1A6EE108}.Release|Win32.Build.0 = Release|Win32 - {EE157390-1E85-416C-946E-620E32C9AD33}.Debug|Win32.ActiveCfg = Debug|Win32 - {EE157390-1E85-416C-946E-620E32C9AD33}.Debug|Win32.Build.0 = Debug|Win32 - {EE157390-1E85-416C-946E-620E32C9AD33}.Release|Win32.ActiveCfg = Release|Win32 - {EE157390-1E85-416C-946E-620E32C9AD33}.Release|Win32.Build.0 = Release|Win32 - {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Debug|Win32.ActiveCfg = Debug|Win32 - {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Debug|Win32.Build.0 = Debug|Win32 - {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Release|Win32.ActiveCfg = Release|Win32 - {57FAF32E-49FD-491F-895D-132D0D5EFE0A}.Release|Win32.Build.0 = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Debug|Win32.Build.0 = Debug|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|Win32.ActiveCfg = Release|Win32 - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA}.Release|Win32.Build.0 = Release|Win32 - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Debug|Win32.ActiveCfg = Debug|Win32 - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Debug|Win32.Build.0 = Debug|Win32 - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Release|Win32.ActiveCfg = Release|Win32 - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C}.Release|Win32.Build.0 = Release|Win32 - {92BFA534-C419-4EB2-AAA3-510653F38F08}.Debug|Win32.ActiveCfg = Debug|Win32 - {92BFA534-C419-4EB2-AAA3-510653F38F08}.Debug|Win32.Build.0 = Debug|Win32 - {92BFA534-C419-4EB2-AAA3-510653F38F08}.Release|Win32.ActiveCfg = Release|Win32 - {92BFA534-C419-4EB2-AAA3-510653F38F08}.Release|Win32.Build.0 = Release|Win32 - {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Debug|Win32.ActiveCfg = Debug|Win32 - {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Debug|Win32.Build.0 = Debug|Win32 - {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Release|Win32.ActiveCfg = Release|Win32 - {B495B6D9-AF84-479D-B30A-313C16EF8BFD}.Release|Win32.Build.0 = Release|Win32 - {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Debug|Win32.ActiveCfg = Debug|Win32 - {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Debug|Win32.Build.0 = Debug|Win32 - {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Release|Win32.ActiveCfg = Release|Win32 - {79EF9F1D-E211-4ED1-91D2-FC935AB3A872}.Release|Win32.Build.0 = Release|Win32 - {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Debug|Win32.ActiveCfg = Debug|Win32 - {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Debug|Win32.Build.0 = Debug|Win32 - {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Release|Win32.ActiveCfg = Release|Win32 - {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15}.Release|Win32.Build.0 = Release|Win32 - {DCF01B1C-5268-44F3-9130-D647FABFB663}.Debug|Win32.ActiveCfg = Debug|Win32 - {DCF01B1C-5268-44F3-9130-D647FABFB663}.Debug|Win32.Build.0 = Debug|Win32 - {DCF01B1C-5268-44F3-9130-D647FABFB663}.Release|Win32.ActiveCfg = Release|Win32 - {DCF01B1C-5268-44F3-9130-D647FABFB663}.Release|Win32.Build.0 = Release|Win32 - {3CA97077-6210-4362-998A-D15A35EEAA08}.Debug|Win32.ActiveCfg = Debug|Win32 - {3CA97077-6210-4362-998A-D15A35EEAA08}.Debug|Win32.Build.0 = Debug|Win32 - {3CA97077-6210-4362-998A-D15A35EEAA08}.Release|Win32.ActiveCfg = Release|Win32 - {3CA97077-6210-4362-998A-D15A35EEAA08}.Release|Win32.Build.0 = Release|Win32 - {729EF28E-38C9-40DE-A138-87785F021411}.Debug|Win32.ActiveCfg = Debug|Win32 - {729EF28E-38C9-40DE-A138-87785F021411}.Release|Win32.ActiveCfg = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|Win32.ActiveCfg = Debug|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Debug|Win32.Build.0 = Debug|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|Win32.ActiveCfg = Release|Win32 - {504B3154-7A4F-459D-9877-B951021C3F1F}.Release|Win32.Build.0 = Release|Win32 - {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Debug|Win32.ActiveCfg = Debug|Win32 - {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Debug|Win32.Build.0 = Debug|Win32 - {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Release|Win32.ActiveCfg = Release|Win32 - {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335}.Release|Win32.Build.0 = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|Win32.ActiveCfg = Debug|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Debug|Win32.Build.0 = Debug|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|Win32.ActiveCfg = Release|Win32 - {DEB01ACB-D65F-4A62-AED9-58C1054499E9}.Release|Win32.Build.0 = Release|Win32 - {01D63BF5-7798-4746-852A-4B45229BB735}.Debug|Win32.ActiveCfg = Debug|Win32 - {01D63BF5-7798-4746-852A-4B45229BB735}.Release|Win32.ActiveCfg = Release|Win32 - {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Debug|Win32.ActiveCfg = Debug|Win32 - {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Release|Win32.ActiveCfg = Release|Win32 - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Debug|Win32.ActiveCfg = Debug|Win32 - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Release|Win32.ActiveCfg = Release|Win32 - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Debug|Win32.ActiveCfg = Debug|Win32 - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Release|Win32.ActiveCfg = Release|Win32 - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Debug|Win32.ActiveCfg = Debug|Win32 - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Release|Win32.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {B5A00BFA-6083-4FAE-A097-71642D6473B5} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {1C320193-46A6-4B34-9C56-8AB584FC1B56} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {18B1F35A-10F8-4287-9B37-2D10501B0B38} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {72782932-37CC-46AE-8C7F-9A7B1A6EE108} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {504B3154-7A4F-459D-9877-B951021C3F1F} = {5377DC3A-DB96-4819-8AAF-2A75F3A69119} - {746F3632-5BB2-4570-9453-31D6D58A7D8E} = {493A1DB9-6E7C-48C7-93B5-F75C3C25B9DF} - {DEB01ACB-D65F-4A62-AED9-58C1054499E9} = {493A1DB9-6E7C-48C7-93B5-F75C3C25B9DF} - {592CF22D-3F8F-4A77-A174-130D77B7623B} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} - {C98AF157-352E-4737-BD30-A24E2647F5AE} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} - {EE157390-1E85-416C-946E-620E32C9AD33} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} - {57FAF32E-49FD-491F-895D-132D0D5EFE0A} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} - {92BFA534-C419-4EB2-AAA3-510653F38F08} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {B495B6D9-AF84-479D-B30A-313C16EF8BFD} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {729EF28E-38C9-40DE-A138-87785F021411} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {79EF9F1D-E211-4ED1-91D2-FC935AB3A872} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} - {429C907B-97D1-4B2D-9B0E-A14A5BFDAD15} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} - {DCF01B1C-5268-44F3-9130-D647FABFB663} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} - {3CA97077-6210-4362-998A-D15A35EEAA08} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} - {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} - {01D63BF5-7798-4746-852A-4B45229BB735} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} - {4714EF49-BFD5-4B22-95F7-95A07F1EAC25} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} - EndGlobalSection -EndGlobal diff --git a/libs/unimrcp/unimrcp.sln b/libs/unimrcp/unimrcp.sln index 3f70c4508e..10b74f6232 100644 --- a/libs/unimrcp/unimrcp.sln +++ b/libs/unimrcp/unimrcp.sln @@ -35,6 +35,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpserver", "libs\mrcp-ser ProjectSection(ProjectDependencies) = postProject {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {12A49562-BAB9-43A3-A21D-15B60BBB4C31} {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} + {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunimrcpserver", "platforms\libunimrcp-server\libunimrcpserver.vcproj", "{C98AF157-352E-4737-BD30-A24E2647F5AE}" @@ -53,6 +54,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpclient", "libs\mrcp-client\mrcpclient.vcproj", "{72782932-37CC-46AE-8C7F-9A7B1A6EE108}" ProjectSection(ProjectDependencies) = postProject {12A49562-BAB9-43A3-A21D-15B60BBB4C31} = {12A49562-BAB9-43A3-A21D-15B60BBB4C31} + {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} = {A9EDAC04-6A5F-4BA7-BC0D-CCE7B255B6EA} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libunimrcpclient", "platforms\libunimrcp-client\libunimrcpclient.vcproj", "{EE157390-1E85-416C-946E-620E32C9AD33}" @@ -133,18 +135,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unimrcpservice", "build\too {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} = {13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcppocketsphinx", "plugins\mrcp-pocketsphinx\mrcppocketsphinx.vcproj", "{3C614AE8-B611-4D43-A9AF-1CAA440A9F69}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpflite", "plugins\mrcp-flite\mrcpflite.vcproj", "{56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}" - ProjectSection(ProjectDependencies) = postProject - {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preparesphinx", "build\tools\preparesphinx.vcproj", "{71D62A04-8EF6-4C6B-AC12-0C15A875E53A}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asrclient", "platforms\asr-client\asrclient.vcproj", "{6B83AC6D-01CE-4E1C-81CE-02AD8116C684}" ProjectSection(ProjectDependencies) = postProject {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3} = {272FAFA8-2B2F-4716-B95F-3B37CF2E0CB3} @@ -181,8 +171,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client-profiles", "client-p conf\client-profiles\unimrcp.xml = conf\client-profiles\unimrcp.xml EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "svnrev", "build\svnrev\svnrev.vcproj", "{49AAB3FE-63D3-41CA-B92B-65828B79902B}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demoverifier", "plugins\demo-verifier\demoverifier.vcproj", "{F7563CAD-5C95-46E5-89B7-0953C6C6E746}" ProjectSection(ProjectDependencies) = postProject {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} = {843425BE-9A9A-44F4-A4E3-4B57D6ABD53C} @@ -380,18 +368,6 @@ Global {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Debug|x64.ActiveCfg = Debug|x64 {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Release|Win32.ActiveCfg = Release|Win32 {4714EF49-BFD5-4B22-95F7-95A07F1EAC25}.Release|x64.ActiveCfg = Release|x64 - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Debug|Win32.ActiveCfg = Debug|Win32 - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Debug|x64.ActiveCfg = Debug|x64 - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Release|Win32.ActiveCfg = Release|Win32 - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69}.Release|x64.ActiveCfg = Release|x64 - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Debug|Win32.ActiveCfg = Debug|Win32 - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Debug|x64.ActiveCfg = Debug|x64 - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Release|Win32.ActiveCfg = Release|Win32 - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556}.Release|x64.ActiveCfg = Release|x64 - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Debug|Win32.ActiveCfg = Debug|Win32 - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Debug|x64.ActiveCfg = Debug|x64 - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Release|Win32.ActiveCfg = Release|Win32 - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A}.Release|x64.ActiveCfg = Release|x64 {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|Win32.ActiveCfg = Debug|Win32 {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|Win32.Build.0 = Debug|Win32 {6B83AC6D-01CE-4E1C-81CE-02AD8116C684}.Debug|x64.ActiveCfg = Debug|x64 @@ -424,16 +400,14 @@ Global {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|Win32.Build.0 = Release|Win32 {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|x64.ActiveCfg = Release|x64 {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2}.Release|x64.Build.0 = Release|x64 - {49AAB3FE-63D3-41CA-B92B-65828B79902B}.Debug|Win32.ActiveCfg = Debug|Win32 - {49AAB3FE-63D3-41CA-B92B-65828B79902B}.Debug|x64.ActiveCfg = Debug|x64 - {49AAB3FE-63D3-41CA-B92B-65828B79902B}.Release|Win32.ActiveCfg = Release|Win32 - {49AAB3FE-63D3-41CA-B92B-65828B79902B}.Release|x64.ActiveCfg = Release|x64 {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|Win32.ActiveCfg = Debug|Win32 {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|Win32.Build.0 = Debug|Win32 - {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|x64.ActiveCfg = Debug|Win32 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|x64.ActiveCfg = Debug|x64 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Debug|x64.Build.0 = Debug|x64 {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|Win32.ActiveCfg = Release|Win32 {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|Win32.Build.0 = Release|Win32 - {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|x64.ActiveCfg = Release|Win32 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|x64.ActiveCfg = Release|x64 + {F7563CAD-5C95-46E5-89B7-0953C6C6E746}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -459,8 +433,6 @@ Global {CD1C52C1-D8E1-4654-AE65-6CCAB38DE894} = {8E282AE2-038C-49FE-AC67-BC9615AFD800} {92BFA534-C419-4EB2-AAA3-510653F38F08} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} {B495B6D9-AF84-479D-B30A-313C16EF8BFD} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {3C614AE8-B611-4D43-A9AF-1CAA440A9F69} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} - {56F6FB96-2BC7-4CAE-A8BF-6A0FAEC90556} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} {5AFB8B04-AEB9-408C-B53E-AFBC44B5F3F2} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} {F7563CAD-5C95-46E5-89B7-0953C6C6E746} = {09BABD45-8F30-4F99-B8B8-8DD78F6804DB} {79EF9F1D-E211-4ED1-91D2-FC935AB3A872} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} @@ -470,8 +442,6 @@ Global {17A33F3F-BAF5-403F-8EF4-FECDA7D9A335} = {AC4356E8-48A1-4D2D-AFB1-11CF30B974CD} {01D63BF5-7798-4746-852A-4B45229BB735} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} {4714EF49-BFD5-4B22-95F7-95A07F1EAC25} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} - {71D62A04-8EF6-4C6B-AC12-0C15A875E53A} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} - {49AAB3FE-63D3-41CA-B92B-65828B79902B} = {62083CC3-13BF-49EA-BFE8-4C9337C0D82C} {F2D6C1AF-0C05-4695-84AF-15A2F92F9899} = {9155EBB8-E7DD-49AE-A86A-7B90B9F09888} EndGlobalSection EndGlobal diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index 8e85cf2960..7f65bd406a 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -93,6 +93,10 @@ struct mod_unimrcp_globals { char *unimrcp_max_connection_count; /** request-timeout config */ char *unimrcp_request_timeout; + /** rx-buffer-size */ + char *unimrcp_rx_buffer_size; + /** tx-buffer-size */ + char *unimrcp_tx_buffer_size; /** offer-new-connection config */ char *unimrcp_offer_new_connection; /** default-tts-profile config */ @@ -173,6 +177,10 @@ static switch_xml_config_item_t instructions[] = { "Fire profile events (true|false)"), SWITCH_CONFIG_ITEM_STRING_STRDUP("request-timeout", CONFIG_REQUIRED, &globals.unimrcp_request_timeout, "10000", "", "Maximum time to wait for server response to a request"), + SWITCH_CONFIG_ITEM_STRING_STRDUP("connection-rx-buffer-size", 0, &globals.unimrcp_rx_buffer_size, "1024", "", + "Maximum time to wait for server response to a request"), + SWITCH_CONFIG_ITEM_STRING_STRDUP("connection-tx-buffer-size", 0, &globals.unimrcp_tx_buffer_size, "1024", "", + "Maximum time to wait for server response to a request"), SWITCH_CONFIG_ITEM_END() }; @@ -258,10 +266,12 @@ struct audio_queue { switch_size_t waiting; /** name of this queue (for logging) */ char *name; + /** optional session uuid associated with this queue (for logging) */ + char *session_uuid; }; typedef struct audio_queue audio_queue_t; -static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *name, switch_memory_pool_t *pool); +static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *name, const char *session_uuid, switch_memory_pool_t *pool); static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len); static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch_size_t *data_len, int block); static switch_status_t audio_queue_clear(audio_queue_t *queue); @@ -309,6 +319,8 @@ typedef enum speech_channel_state speech_channel_state_t; struct speech_channel { /** the name of this channel (for logging) */ char *name; + /** optional session associated w/ this channel */ + char *session_uuid; /** The profile used by this channel */ profile_t *profile; /** type of channel */ @@ -351,7 +363,7 @@ static apt_bool_t speech_on_channel_remove(mrcp_application_t *application, mrcp mrcp_sig_status_code_e status); /* speech_channel funcs */ -static switch_status_t speech_channel_create(speech_channel_t ** schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app, +static switch_status_t speech_channel_create(speech_channel_t ** schannel, const char *name, const char *session_uuid, speech_channel_type_t type, mod_unimrcp_application_t *app, uint16_t rate, switch_memory_pool_t *pool); static mpf_termination_t *speech_channel_create_mpf_termination(speech_channel_t *schannel); static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t *profile); @@ -595,10 +607,11 @@ static const char *skip_initial_whitespace(const char *text) * * @param audio_queue the created queue * @param name the name of this queue (for logging) + * @param session_uuid optional session associated with this channel * @param pool memory pool to allocate queue from * @return SWITCH_STATUS_SUCCESS if successful. SWITCH_STATUS_FALSE if unable to allocate queue */ -static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const char *name, switch_memory_pool_t *pool) +static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const char *name, const char *session_uuid, switch_memory_pool_t *pool) { switch_status_t status = SWITCH_STATUS_SUCCESS; audio_queue_t *laudio_queue = NULL; @@ -606,8 +619,12 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch int flags; #endif char *lname = ""; + char *lsession_uuid = NULL; *audio_queue = NULL; + lname = zstr(name) ? "" : switch_core_strdup(pool, name); + lsession_uuid = zstr(session_uuid) ? NULL : switch_core_strdup(pool, session_uuid); + if (zstr(name)) { lname = ""; } else { @@ -615,27 +632,28 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch } if ((laudio_queue = (audio_queue_t *) switch_core_alloc(pool, sizeof(audio_queue_t))) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue\n", lname); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(lsession_uuid), SWITCH_LOG_ERROR, "(%s) unable to create audio queue\n", lname); status = SWITCH_STATUS_FALSE; goto done; } laudio_queue->name = lname; + laudio_queue->session_uuid = lsession_uuid; if (switch_buffer_create(pool, &laudio_queue->buffer, AUDIO_QUEUE_SIZE) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue buffer\n", laudio_queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(lsession_uuid), SWITCH_LOG_ERROR, "(%s) unable to create audio queue buffer\n", laudio_queue->name); status = SWITCH_STATUS_FALSE; goto done; } if (switch_mutex_init(&laudio_queue->mutex, SWITCH_MUTEX_UNNESTED, pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue mutex\n", laudio_queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(lsession_uuid), SWITCH_LOG_ERROR, "(%s) unable to create audio queue mutex\n", laudio_queue->name); status = SWITCH_STATUS_FALSE; goto done; } if (switch_thread_cond_create(&laudio_queue->cond, pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue condition variable\n", laudio_queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(lsession_uuid), SWITCH_LOG_ERROR, "(%s) unable to create audio queue condition variable\n", laudio_queue->name); status = SWITCH_STATUS_FALSE; goto done; } @@ -643,17 +661,17 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch flags = SWITCH_FOPEN_CREATE | SWITCH_FOPEN_WRITE | SWITCH_FOPEN_TRUNCATE | SWITCH_FOPEN_BINARY; strcpy(laudio_queue->file_read_name, "/tmp/mod_unimrcp_rx_XXXXXX"); if (switch_file_mktemp(&laudio_queue->file_read, laudio_queue->file_read_name, flags, pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue read file\n", laudio_queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(laudio_queue->session_uuid), SWITCH_LOG_ERROR, "(%s) unable to create audio queue read file\n", laudio_queue->name); laudio_queue->file_read = NULL; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) queue rx saved to %s\n", laudio_queue->name, laudio_queue->file_read_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(laudio_queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) queue rx saved to %s\n", laudio_queue->name, laudio_queue->file_read_name); } strcpy(laudio_queue->file_write_name, "/tmp/mod_unimrcp_tx_XXXXXX"); if (switch_file_mktemp(&laudio_queue->file_write, laudio_queue->file_write_name, flags, pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue write file\n", laudio_queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(laudio_queue->session_uuid), SWITCH_LOG_ERROR, "(%s) unable to create audio queue write file\n", laudio_queue->name); laudio_queue->file_write = NULL; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) queue tx saved to %s\n", laudio_queue->name, laudio_queue->file_write_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(laudio_queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) queue tx saved to %s\n", laudio_queue->name, laudio_queue->file_write_name); } #endif @@ -661,7 +679,7 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch laudio_queue->read_bytes = 0; laudio_queue->waiting = 0; *audio_queue = laudio_queue; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue created\n", laudio_queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(laudio_queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) audio queue created\n", laudio_queue->name); done: @@ -696,7 +714,7 @@ static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switc if (switch_buffer_write(queue->buffer, data, *data_len) > 0) { queue->write_bytes = queue->write_bytes + *data_len; #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue write total = %ld\trequested = %ld\n", queue->name, queue->write_bytes, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) audio queue write total = %ld\trequested = %ld\n", queue->name, queue->write_bytes, *data_len); #endif if (queue->waiting <= switch_buffer_inuse(queue->buffer)) { @@ -704,7 +722,7 @@ static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switc } } else { *data_len = 0; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue overflow!\n", queue->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) audio queue overflow!\n", queue->name); status = SWITCH_STATUS_FALSE; } @@ -761,7 +779,7 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch *data_len = switch_buffer_read(queue->buffer, data, requested); queue->read_bytes = queue->read_bytes + *data_len; #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name, queue->read_bytes, *data_len, requested); if (queue->file_read) { switch_file_write(queue->file_read, data, &len); @@ -829,7 +847,7 @@ static switch_status_t audio_queue_destroy(audio_queue_t *queue) queue->file_write = NULL; } #endif - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue destroyed\n", name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(queue->session_uuid), SWITCH_LOG_DEBUG, "(%s) audio queue destroyed\n", name); } return SWITCH_STATUS_SUCCESS; } @@ -839,13 +857,14 @@ static switch_status_t audio_queue_destroy(audio_queue_t *queue) * * @param schannel the created channel * @param name the name of the channel + * @param session_uuid optional session associated with this channel * @param type the type of channel to create * @param app the application * @param rate the rate to use * @param pool the memory pool to use * @return SWITCH_STATUS_SUCCESS if successful. SWITCH_STATUS_FALSE if the channel cannot be allocated. */ -static switch_status_t speech_channel_create(speech_channel_t ** schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app, +static switch_status_t speech_channel_create(speech_channel_t ** schannel, const char *name, const char *session_uuid, speech_channel_type_t type, mod_unimrcp_application_t *app, uint16_t rate, switch_memory_pool_t *pool) { switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -868,17 +887,15 @@ static switch_status_t speech_channel_create(speech_channel_t ** schannel, const if (switch_mutex_init(&schan->mutex, SWITCH_MUTEX_UNNESTED, pool) != SWITCH_STATUS_SUCCESS || switch_thread_cond_create(&schan->cond, pool) != SWITCH_STATUS_SUCCESS || - audio_queue_create(&schan->audio_queue, name, pool) != SWITCH_STATUS_SUCCESS) { + audio_queue_create(&schan->audio_queue, name, session_uuid, pool) != SWITCH_STATUS_SUCCESS) { status = SWITCH_STATUS_FALSE; goto done; } switch_core_hash_init(&schan->params); schan->data = NULL; - if (zstr(name)) { - schan->name = ""; - } else { - schan->name = switch_core_strdup(pool, name); - } + schan->name = zstr(name) ? "" : switch_core_strdup(pool, name); + schan->session_uuid = zstr(session_uuid) ? NULL : switch_core_strdup(pool, session_uuid); + *schannel = schan; done: @@ -902,11 +919,11 @@ static switch_status_t speech_channel_destroy(speech_channel_t *schannel) int warned = 0; mrcp_application_session_terminate(schannel->unimrcp_session); /* wait forever for session to terminate. Log WARNING if this starts taking too long */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Waiting for MRCP session to terminate\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Waiting for MRCP session to terminate\n", schannel->name); while (schannel->state != SPEECH_CHANNEL_CLOSED) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) MRCP session has not terminated after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) MRCP session has not terminated after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } } @@ -992,14 +1009,15 @@ static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t /* create MRCP session */ if ((schannel->unimrcp_session = mrcp_application_session_create(schannel->application->app, profile->name, schannel)) == NULL) { /* profile doesn't exist? */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create session with %s\n", schannel->name, profile->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Unable to create session with %s\n", schannel->name, profile->name); status = SWITCH_STATUS_RESTART; goto done; } + mrcp_application_session_name_set(schannel->unimrcp_session, schannel->name); /* create audio termination and add to channel */ if ((termination = speech_channel_create_mpf_termination(schannel)) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create termination with %s\n", schannel->name, profile->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Unable to create termination with %s\n", schannel->name, profile->name); mrcp_application_session_destroy(schannel->unimrcp_session); status = SWITCH_STATUS_FALSE; goto done; @@ -1010,7 +1028,7 @@ static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t resource_type = MRCP_RECOGNIZER_RESOURCE; } if ((schannel->unimrcp_channel = mrcp_application_channel_create(schannel->unimrcp_session, resource_type, termination, NULL, schannel)) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create channel with %s\n", schannel->name, profile->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Unable to create channel with %s\n", schannel->name, profile->name); mrcp_application_session_destroy(schannel->unimrcp_session); status = SWITCH_STATUS_FALSE; goto done; @@ -1018,7 +1036,7 @@ static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t /* add channel to session... this establishes the connection to the MRCP server */ if (mrcp_application_channel_add(schannel->unimrcp_session, schannel->unimrcp_channel) != TRUE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to add channel to session with %s\n", schannel->name, profile->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Unable to add channel to session with %s\n", schannel->name, profile->name); mrcp_application_session_destroy(schannel->unimrcp_session); status = SWITCH_STATUS_FALSE; goto done; @@ -1029,19 +1047,19 @@ static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t while (schannel->state == SPEECH_CHANNEL_CLOSED) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) MRCP session has not opened after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) MRCP session has not opened after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } if (schannel->state == SPEECH_CHANNEL_READY) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) channel is ready\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) channel is ready\n", schannel->name); } else if (schannel->state == SPEECH_CHANNEL_CLOSED) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Timed out waiting for channel to be ready\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Timed out waiting for channel to be ready\n", schannel->name); /* can't retry */ status = SWITCH_STATUS_FALSE; } else if (schannel->state == SPEECH_CHANNEL_ERROR) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Terminating MRCP session\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Terminating MRCP session\n", schannel->name); if (!mrcp_application_session_terminate(schannel->unimrcp_session)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Unable to terminate application session\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Unable to terminate application session\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } @@ -1051,7 +1069,7 @@ static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t while (schannel->state == SPEECH_CHANNEL_ERROR) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) MRCP session has not cleaned up after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) MRCP session has not cleaned up after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } if (schannel->state != SPEECH_CHANNEL_CLOSED) { @@ -1092,7 +1110,7 @@ static switch_status_t synth_channel_speak(speech_channel_t *schannel, const cha mrcp_message = mrcp_application_message_create(schannel->unimrcp_session, schannel->unimrcp_channel, SYNTHESIZER_SPEAK); if (mrcp_message == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Failed to create SPEAK message\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Failed to create SPEAK message\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } @@ -1133,7 +1151,7 @@ static switch_status_t synth_channel_speak(speech_channel_t *schannel, const cha while (schannel->state == SPEECH_CHANNEL_READY) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) SPEAK IN-PROGRESS not received after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) SPEAK IN-PROGRESS not received after %d ms\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } if (schannel->state != SPEECH_CHANNEL_PROCESSING) { @@ -1171,18 +1189,18 @@ static switch_status_t synth_channel_set_params(speech_channel_t *schannel, mrcp if (!zstr(param_name) && !zstr(param_val)) { unimrcp_param_id_t *id = (unimrcp_param_id_t *) switch_core_hash_find(schannel->application->param_id_map, param_name); if (id) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s: %s\n", schannel->name, param_name, param_val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) %s: %s\n", schannel->name, param_name, param_val); synth_channel_set_header(schannel, id->id, param_val, msg, synth_hdr); } else { apt_str_t apt_param_name = { 0 }; apt_str_t apt_param_val = { 0 }; /* this is probably a vendor-specific MRCP param */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) (vendor-specific value) %s: %s\n", schannel->name, param_name, param_val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) (vendor-specific value) %s: %s\n", schannel->name, param_name, param_val); apt_string_set(&apt_param_name, param_name); /* copy isn't necessary since apt_pair_array_append will do it */ apt_string_set(&apt_param_val, param_val); if (!gen_hdr->vendor_specific_params) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) creating vendor specific pair array\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) creating vendor specific pair array\n", schannel->name); gen_hdr->vendor_specific_params = apt_pair_array_create(10, msg->pool); } apt_pair_array_append(gen_hdr->vendor_specific_params, &apt_param_name, &apt_param_val, msg->pool); @@ -1218,7 +1236,7 @@ static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int } else if (!strcasecmp("neutral", val)) { synth_hdr->voice_param.gender = VOICE_GENDER_NEUTRAL; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice gender, %s\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) ignoring invalid voice gender, %s\n", schannel->name, val); break; } mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_GENDER); @@ -1230,7 +1248,7 @@ static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int synth_hdr->voice_param.age = age; mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_AGE); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice age, %s\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) ignoring invalid voice age, %s\n", schannel->name, val); } break; } @@ -1241,7 +1259,7 @@ static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int synth_hdr->voice_param.variant = variant; mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_VARIANT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice variant, %s\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) ignoring invalid voice variant, %s\n", schannel->name, val); } break; } @@ -1285,7 +1303,7 @@ static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int synth_hdr->prosody_param.volume.type = PROSODY_VOLUME_TYPE_LABEL; synth_hdr->prosody_param.volume.value.label = PROSODY_VOLUME_DEFAULT; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid prosody volume, %s\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) ignoring invalid prosody volume, %s\n", schannel->name, val); break; } mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_PROSODY_VOLUME); @@ -1314,7 +1332,7 @@ static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int synth_hdr->prosody_param.rate.type = PROSODY_RATE_TYPE_LABEL; synth_hdr->prosody_param.rate.value.label = PROSODY_RATE_DEFAULT; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid prosody rate, %s\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) ignoring invalid prosody rate, %s\n", schannel->name, val); break; } mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_PROSODY_RATE); @@ -1340,7 +1358,7 @@ static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int case SYNTHESIZER_HEADER_LOAD_LEXICON: case SYNTHESIZER_HEADER_LEXICON_SEARCH_ORDER: default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unsupported SYNTHESIZER_HEADER type\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) unsupported SYNTHESIZER_HEADER type\n", schannel->name); } return SWITCH_STATUS_SUCCESS; @@ -1366,11 +1384,11 @@ static switch_status_t speech_channel_stop(speech_channel_t *schannel) } else { method = RECOGNIZER_STOP; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Stopping %s\n", schannel->name, speech_channel_type_to_string(schannel->type)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Stopping %s\n", schannel->name, speech_channel_type_to_string(schannel->type)); /* Send STOP to MRCP server */ mrcp_message = mrcp_application_message_create(schannel->unimrcp_session, schannel->unimrcp_channel, method); if (mrcp_message == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Failed to create STOP message\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Failed to create STOP message\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } @@ -1378,17 +1396,17 @@ static switch_status_t speech_channel_stop(speech_channel_t *schannel) while (schannel->state == SPEECH_CHANNEL_PROCESSING) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) STOP has not COMPLETED after %d ms.\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) STOP has not COMPLETED after %d ms.\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } if (schannel->state == SPEECH_CHANNEL_ERROR) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Channel error\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Channel error\n", schannel->name); schannel->state = SPEECH_CHANNEL_ERROR; status = SWITCH_STATUS_FALSE; goto done; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s stopped\n", schannel->name, speech_channel_type_to_string(schannel->type)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) %s stopped\n", schannel->name, speech_channel_type_to_string(schannel->type)); } else if (schannel->state == SPEECH_CHANNEL_DONE) { speech_channel_set_state_unlocked(schannel, SPEECH_CHANNEL_READY); } @@ -1436,7 +1454,7 @@ static switch_status_t speech_channel_set_param(speech_channel_t *schannel, cons p = switch_core_strdup(schannel->memory_pool, param); } v = switch_core_strdup(schannel->memory_pool, val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) param = %s, val = %s\n", schannel->name, p, v); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) param = %s, val = %s\n", schannel->name, p, v); switch_core_hash_insert(schannel->params, p, v); } switch_mutex_unlock(schannel->mutex); @@ -1559,7 +1577,7 @@ static switch_status_t speech_channel_set_state_unlocked(speech_channel_t *schan audio_queue_signal(schannel->audio_queue); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->state), + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->state), speech_channel_state_to_string(state)); schannel->state = state; switch_thread_cond_signal(schannel->cond); @@ -1586,27 +1604,33 @@ static switch_status_t synth_speech_open(switch_speech_handle_t *sh, const char profile_t *profile = NULL; int speech_channel_number = get_next_speech_channel_number(); char *name = NULL; + char *session_uuid = NULL; switch_hash_index_t *hi = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n", sh->name, sh->rate, - sh->speed, sh->samples, sh->voice, sh->engine, sh->param); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "voice = %s, rate = %d\n", voice_name, rate); - /* Name the channel */ if (profile_name && strchr(profile_name, ':')) { /* Profile has session name appended to it. Pick it out */ profile_name = switch_core_strdup(sh->memory_pool, profile_name); - name = strchr(profile_name, ':'); - *name = '\0'; - name++; - name = switch_core_sprintf(sh->memory_pool, "%s TTS-%d", name, speech_channel_number); + session_uuid = strchr(profile_name, ':'); + *session_uuid = '\0'; + session_uuid++; + session_uuid = switch_core_strdup(sh->memory_pool, session_uuid); } else { - name = switch_core_sprintf(sh->memory_pool, "TTS-%d", speech_channel_number); + /* check if session is associated w/ this memory pool */ + switch_core_session_t *session = switch_core_memory_pool_get_data(sh->memory_pool, "__session"); + if (session) { + session_uuid = switch_core_session_get_uuid(session); + } } + name = switch_core_sprintf(sh->memory_pool, "TTS-%d", speech_channel_number); + + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_uuid), SWITCH_LOG_INFO, + "speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n", sh->name, sh->rate, + sh->speed, sh->samples, sh->voice, sh->engine, sh->param); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_uuid), SWITCH_LOG_INFO, "voice = %s, rate = %d\n", voice_name, rate); /* Allocate the channel */ - if (speech_channel_create(&schannel, name, SPEECH_CHANNEL_SYNTHESIZER, &globals.synth, (uint16_t) rate, sh->memory_pool) != SWITCH_STATUS_SUCCESS) { + if (speech_channel_create(&schannel, name, session_uuid, SPEECH_CHANNEL_SYNTHESIZER, &globals.synth, (uint16_t) rate, sh->memory_pool) != SWITCH_STATUS_SUCCESS) { status = SWITCH_STATUS_FALSE; goto done; } @@ -1619,7 +1643,7 @@ static switch_status_t synth_speech_open(switch_speech_handle_t *sh, const char } profile = (profile_t *) switch_core_hash_find(globals.profiles, profile_name); if (!profile) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_uuid), SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name); status = SWITCH_STATUS_FALSE; goto done; } @@ -1706,7 +1730,7 @@ static switch_status_t synth_speech_read_tts(switch_speech_handle_t *sh, void *d /* pad data, if not enough read */ if (bytes_read < *datalen) { #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) adding %ld bytes of padding\n", schannel->name, *datalen - bytes_read); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) adding %ld bytes of padding\n", schannel->name, *datalen - bytes_read); #endif memset((uint8_t *) data + bytes_read, schannel->silence, *datalen - bytes_read); } @@ -1804,7 +1828,7 @@ static apt_bool_t speech_on_session_terminate(mrcp_application_t *application, m { speech_channel_t *schannel = (speech_channel_t *) mrcp_application_session_object_get(session); switch_event_t *event = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Destroying MRCP session\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Destroying MRCP session\n", schannel->name); mrcp_application_session_destroy(session); /* notify of channel close */ @@ -1869,7 +1893,7 @@ static apt_bool_t speech_on_channel_add(mrcp_application_t *application, mrcp_se if (descriptor->name.length) { strncpy(codec_name, descriptor->name.buf, sizeof(codec_name) - 1 ); } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s channel is ready, codec = %s, sample rate = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) %s channel is ready, codec = %s, sample rate = %d\n", schannel->name, speech_channel_type_to_string(schannel->type), codec_name, schannel->rate); speech_channel_set_state(schannel, SPEECH_CHANNEL_READY); @@ -1889,7 +1913,7 @@ static apt_bool_t speech_on_channel_add(mrcp_application_t *application, mrcp_se error: if (schannel) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) %s channel error!\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) %s channel error!\n", schannel->name, speech_channel_type_to_string(schannel->type)); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } else { @@ -1913,11 +1937,11 @@ static apt_bool_t speech_on_channel_remove(mrcp_application_t *application, mrcp mrcp_sig_status_code_e status) { speech_channel_t *schannel = (speech_channel_t *) mrcp_application_channel_object_get(channel); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) %s channel is removed\n", schannel->name, speech_channel_type_to_string(schannel->type)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_INFO, "(%s) %s channel is removed\n", schannel->name, speech_channel_type_to_string(schannel->type)); schannel->unimrcp_channel = NULL; if (session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Terminating MRCP session\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Terminating MRCP session\n", schannel->name); mrcp_application_session_terminate(session); } @@ -1942,11 +1966,11 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp /* received the response to SPEAK request */ if (message->start_line.request_state == MRCP_REQUEST_STATE_INPROGRESS) { /* waiting for SPEAK-COMPLETE event */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) REQUEST IN PROGRESS\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) REQUEST IN PROGRESS\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_PROCESSING); } else { /* received unexpected request_state */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected SPEAK response, request_state = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected SPEAK response, request_state = %d\n", schannel->name, message->start_line.request_state); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } @@ -1954,17 +1978,17 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp /* received response to the STOP request */ if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) { /* got COMPLETE */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) COMPLETE\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) COMPLETE\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE); } else { /* received unexpected request state */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP response, request_state = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected STOP response, request_state = %d\n", schannel->name, message->start_line.request_state); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } } else { /* received unexpected response */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name, (int) message->start_line.method_id); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } @@ -1972,15 +1996,15 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp /* received MRCP event */ if (message->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) { /* got SPEAK-COMPLETE */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SPEAK-COMPLETE\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) SPEAK-COMPLETE\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name, (int) message->start_line.method_id); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name, message->start_line.message_type); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } @@ -2198,7 +2222,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel) switch_core_hash_this(egk, (void *) &key, NULL, (void *) &grammar); if (grammar->type != GRAMMAR_TYPE_URI && grammar_uri_count != 1) { no_grammar_alone: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Grammar '%s' can only be used alone (not a URI list)\n", schannel->name, key); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Grammar '%s' can only be used alone (not a URI list)\n", schannel->name, key); status = SWITCH_STATUS_FALSE; switch_safe_free(egk); goto done; @@ -2213,7 +2237,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel) switch (grammar_uri_count) { case 0: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) No grammar specified\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) No grammar specified\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; case 1: @@ -2299,7 +2323,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel) while (schannel->state == SPEECH_CHANNEL_READY) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) IN-PROGRESS not received for RECOGNIZE after %d ms.\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) IN-PROGRESS not received for RECOGNIZE after %d ms.\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } if (schannel->state != SPEECH_CHANNEL_PROCESSING) { @@ -2328,7 +2352,7 @@ static switch_status_t recog_channel_load_grammar(speech_channel_t *schannel, co grammar_t *g = NULL; char *ldata = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Loading grammar %s, data = %s\n", schannel->name, name, data); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Loading grammar %s, data = %s\n", schannel->name, name, data); switch_mutex_lock(schannel->mutex); if (schannel->state != SPEECH_CHANNEL_READY) { @@ -2378,7 +2402,7 @@ static switch_status_t recog_channel_load_grammar(speech_channel_t *schannel, co while (schannel->state == SPEECH_CHANNEL_PROCESSING) { if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT && !warned) { warned = 1; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) DEFINE-GRAMMAR not COMPLETED after %d ms.\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) DEFINE-GRAMMAR not COMPLETED after %d ms.\n", schannel->name, SPEECH_CHANNEL_TIMEOUT_USEC / (1000)); } } if (schannel->state != SPEECH_CHANNEL_READY) { @@ -2421,7 +2445,7 @@ static switch_status_t recog_channel_unload_grammar(speech_channel_t *schannel, status = SWITCH_STATUS_FALSE; } else { recognizer_data_t *r = (recognizer_data_t *) schannel->data; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Unloading grammar %s\n", schannel->name, grammar_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Unloading grammar %s\n", schannel->name, grammar_name); switch_core_hash_delete(r->enabled_grammars, grammar_name); switch_core_hash_delete(r->grammars, grammar_name); } @@ -2448,11 +2472,11 @@ static switch_status_t recog_channel_enable_grammar(speech_channel_t *schannel, grammar = (grammar_t *) switch_core_hash_find(r->grammars, grammar_name); if (grammar == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Undefined grammar, %s\n", schannel->name, grammar_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Undefined grammar, %s\n", schannel->name, grammar_name); status = SWITCH_STATUS_FALSE; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Enabling grammar %s\n", schannel->name, grammar_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Enabling grammar %s\n", schannel->name, grammar_name); switch_core_hash_insert(r->enabled_grammars, grammar_name, grammar); } } @@ -2475,7 +2499,7 @@ static switch_status_t recog_channel_disable_grammar(speech_channel_t *schannel, status = SWITCH_STATUS_FALSE; } else { recognizer_data_t *r = (recognizer_data_t *) schannel->data; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Disabling grammar %s\n", schannel->name, grammar_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Disabling grammar %s\n", schannel->name, grammar_name); switch_core_hash_delete(r->enabled_grammars, grammar_name); } @@ -2493,7 +2517,7 @@ static switch_status_t recog_channel_disable_all_grammars(speech_channel_t *scha switch_status_t status = SWITCH_STATUS_SUCCESS; recognizer_data_t *r = (recognizer_data_t *) schannel->data; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Disabling all grammars\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Disabling all grammars\n", schannel->name); switch_core_hash_destroy(&r->enabled_grammars); switch_core_hash_init(&r->enabled_grammars); @@ -2512,9 +2536,9 @@ static switch_status_t recog_channel_check_results(speech_channel_t *schannel) switch_mutex_lock(schannel->mutex); r = (recognizer_data_t *) schannel->data; if (!zstr(r->result)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SUCCESS, have result\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) SUCCESS, have result\n", schannel->name); } else if (r->start_of_input == START_OF_INPUT_RECEIVED) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SUCCESS, start of input\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) SUCCESS, start of input\n", schannel->name); } else { status = SWITCH_STATUS_FALSE; } @@ -2536,11 +2560,11 @@ static switch_status_t recog_channel_start_input_timers(speech_channel_t *schann if (schannel->state == SPEECH_CHANNEL_PROCESSING && !r->timers_started && !r->start_of_input) { mrcp_message_t *mrcp_message; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Starting input timers\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Starting input timers\n", schannel->name); /* Send START-INPUT-TIMERS to MRCP server */ mrcp_message = mrcp_application_message_create(schannel->unimrcp_session, schannel->unimrcp_channel, RECOGNIZER_START_INPUT_TIMERS); if (mrcp_message == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Failed to create START-INPUT-TIMERS message\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Failed to create START-INPUT-TIMERS message\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } @@ -2567,7 +2591,7 @@ static switch_status_t recog_channel_set_start_of_input(speech_channel_t *schann switch_mutex_lock(schannel->mutex); r = (recognizer_data_t *) schannel->data; r->start_of_input = START_OF_INPUT_RECEIVED; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) start of input\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) start of input\n", schannel->name); switch_mutex_unlock(schannel->mutex); return status; } @@ -2586,16 +2610,16 @@ static switch_status_t recog_channel_set_results(speech_channel_t *schannel, con switch_mutex_lock(schannel->mutex); r = (recognizer_data_t *) schannel->data; if (!zstr(r->result)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result is already set\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) result is already set\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } if (zstr(result)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result is NULL\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) result is NULL\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result:\n\n%s\n", schannel->name, result); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) result:\n\n%s\n", schannel->name, result); r->result = switch_core_strdup(schannel->memory_pool, result); done: @@ -2689,18 +2713,18 @@ static switch_status_t recog_channel_set_result_headers(speech_channel_t *schann r = (recognizer_data_t *) schannel->data; if (r->result_headers) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result headers are already set\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) result headers are already set\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } if (!recog_hdr) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result headers are NULL\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) result headers are NULL\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) ASR adding result headers\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) ASR adding result headers\n", schannel->name); if ((status = switch_event_create(&r->result_headers, SWITCH_EVENT_CLONE)) == SWITCH_STATUS_SUCCESS) { @@ -2753,11 +2777,11 @@ static switch_status_t recog_channel_get_results(speech_channel_t *schannel, cha switch_mutex_lock(schannel->mutex); if (!zstr(r->result)) { *result = strdup(r->result); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result:\n\n%s\n", schannel->name, *result ? *result : ""); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) result:\n\n%s\n", schannel->name, *result ? *result : ""); r->result = NULL; r->start_of_input = START_OF_INPUT_REPORTED; } else if (r->start_of_input == START_OF_INPUT_RECEIVED) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) start of input\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) start of input\n", schannel->name); status = SWITCH_STATUS_BREAK; r->start_of_input = START_OF_INPUT_REPORTED; } else { @@ -2815,7 +2839,7 @@ static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp if (!zstr(param_name) && !zstr(param_val)) { unimrcp_param_id_t *id = (unimrcp_param_id_t *) switch_core_hash_find(schannel->application->param_id_map, param_name); if (id) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) \"%s\": \"%s\"\n", schannel->name, param_name, param_val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) \"%s\": \"%s\"\n", schannel->name, param_name, param_val); recog_channel_set_header(schannel, id->id, param_val, msg, recog_hdr); } else if (!strcasecmp(param_name, "define-grammar")) { // This parameter is used internally only, not in MRCP headers @@ -2827,11 +2851,11 @@ static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp /* this is probably a vendor-specific MRCP param */ apt_str_t apt_param_name = { 0 }; apt_str_t apt_param_val = { 0 }; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) (vendor-specific value) %s: %s\n", schannel->name, param_name, param_val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) (vendor-specific value) %s: %s\n", schannel->name, param_name, param_val); apt_string_set(&apt_param_name, param_name); /* copy isn't necessary since apt_pair_array_append will do it */ apt_string_set(&apt_param_val, param_val); if (!gen_hdr->vendor_specific_params) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) creating vendor specific pair array\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) creating vendor specific pair array\n", schannel->name); gen_hdr->vendor_specific_params = apt_pair_array_create(10, msg->pool); } apt_pair_array_append(gen_hdr->vendor_specific_params, &apt_param_name, &apt_param_val, msg->pool); @@ -2882,7 +2906,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->n_best_list_length = n_best_list_length; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_N_BEST_LIST_LENGTH); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid n best list length, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid n best list length, \"%s\"\n", schannel->name, val); } break; } @@ -2892,7 +2916,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->no_input_timeout = no_input_timeout; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_NO_INPUT_TIMEOUT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid no input timeout, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid no input timeout, \"%s\"\n", schannel->name, val); } break; } @@ -2902,7 +2926,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->recognition_timeout = recognition_timeout; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_RECOGNITION_TIMEOUT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid recognition timeout, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid recognition timeout, \"%s\"\n", schannel->name, val); } break; } @@ -2916,7 +2940,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->speech_complete_timeout = speech_complete_timeout; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech complete timeout, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech complete timeout, \"%s\"\n", schannel->name, val); } break; } @@ -2926,7 +2950,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->speech_incomplete_timeout = speech_incomplete_timeout; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech incomplete timeout, \"%s\"\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech incomplete timeout, \"%s\"\n", schannel->name, val); } break; @@ -2937,7 +2961,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->dtmf_interdigit_timeout = dtmf_interdigit_timeout; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf interdigit timeout, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf interdigit timeout, \"%s\"\n", schannel->name, val); } break; } @@ -2947,7 +2971,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->dtmf_term_timeout = dtmf_term_timeout; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf term timeout, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf term timeout, \"%s\"\n", schannel->name, val); } break; } @@ -2956,7 +2980,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->dtmf_term_char = *val; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_TERM_CHAR); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf term char, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf term char, \"%s\"\n", schannel->name, val); } break; @@ -2986,7 +3010,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->hotword_max_duration = hotword_max_duration; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_HOTWORD_MAX_DURATION); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword max duration, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword max duration, \"%s\"\n", schannel->name, val); } break; } @@ -2996,7 +3020,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int recog_hdr->hotword_min_duration = hotword_min_duration; mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_HOTWORD_MIN_DURATION); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword min duration, \"%s\"\n", schannel->name, val); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword min duration, \"%s\"\n", schannel->name, val); } break; } @@ -3042,7 +3066,7 @@ static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int case RECOGNIZER_HEADER_VER_BUFFER_UTTERANCE: default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) unsupported RECOGNIZER header\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_WARNING, "(%s) unsupported RECOGNIZER header\n", schannel->name); } return status; @@ -3082,25 +3106,31 @@ static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec profile_t *profile = NULL; recognizer_data_t *r = NULL; switch_hash_index_t *hi = NULL; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "asr_handle: name = %s, codec = %s, rate = %d, grammar = %s, param = %s\n", - ah->name, ah->codec, ah->rate, ah->grammar, ah->param); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "codec = %s, rate = %d, dest = %s\n", codec, rate, dest); + char *session_uuid = NULL; /* Name the channel */ if (profile_name && strchr(profile_name, ':')) { /* Profile has session name appended to it. Pick it out */ profile_name = switch_core_strdup(ah->memory_pool, profile_name); - name = strchr(profile_name, ':'); - *name = '\0'; - name++; - name = switch_core_sprintf(ah->memory_pool, "%s ASR-%d", name, speech_channel_number); + session_uuid = strchr(profile_name, ':'); + *session_uuid = '\0'; + session_uuid++; + session_uuid = switch_core_strdup(ah->memory_pool, session_uuid); } else { - name = switch_core_sprintf(ah->memory_pool, "ASR-%d", speech_channel_number); + /* check if session is associated w/ this memory pool */ + switch_core_session_t *session = switch_core_memory_pool_get_data(ah->memory_pool, "__session"); + if (session) { + session_uuid = switch_core_session_get_uuid(session); + } } + name = switch_core_sprintf(ah->memory_pool, "ASR-%d", speech_channel_number); + + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_uuid), SWITCH_LOG_INFO, "asr_handle: name = %s, codec = %s, rate = %d, grammar = %s, param = %s\n", + ah->name, ah->codec, ah->rate, ah->grammar, ah->param); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_uuid), SWITCH_LOG_INFO, "codec = %s, rate = %d, dest = %s\n", codec, rate, dest); /* Allocate the channel */ - if (speech_channel_create(&schannel, name, SPEECH_CHANNEL_RECOGNIZER, &globals.recog, (uint16_t) rate, ah->memory_pool) != SWITCH_STATUS_SUCCESS) { + if (speech_channel_create(&schannel, name, session_uuid, SPEECH_CHANNEL_RECOGNIZER, &globals.recog, (uint16_t) rate, ah->memory_pool) != SWITCH_STATUS_SUCCESS) { status = SWITCH_STATUS_FALSE; goto done; } @@ -3118,7 +3148,7 @@ static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec } profile = (profile_t *) switch_core_hash_find(globals.profiles, profile_name); if (!profile) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_uuid), SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name); status = SWITCH_STATUS_FALSE; goto done; } @@ -3162,7 +3192,7 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha grammar_type_t type = GRAMMAR_TYPE_UNKNOWN; char *filename = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar = %s, name = %s\n", schannel->name, grammar, name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) grammar = %s, name = %s\n", schannel->name, grammar, name); grammar = skip_initial_whitespace(grammar); if (zstr(grammar)) { @@ -3179,7 +3209,7 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha /* figure out what type of grammar this is */ if (text_starts_with(grammar, HTTP_ID) || text_starts_with(grammar, FILE_ID) || text_starts_with(grammar, SESSION_ID) || text_starts_with(grammar, BUILTIN_ID)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Grammar is URI\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Grammar is URI\n", schannel->name); type = GRAMMAR_TYPE_URI; grammar_data = grammar; } else if (text_starts_with(grammar, INLINE_ID)) { @@ -3187,7 +3217,7 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha } else { /* grammar points to file containing the grammar text. We assume the MRCP server can't get to this file * so read the data from the file and cache it */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Grammar is inside file\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Grammar is inside file\n", schannel->name); if (switch_is_file_path(grammar)) { filename = switch_mprintf("%s.gram", grammar); } else { @@ -3195,25 +3225,25 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha } grammar_data = NULL; if (switch_file_open(&grammar_file, filename, SWITCH_FOPEN_READ, 0, schannel->memory_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Could not read grammar file: %s\n", schannel->name, filename); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Could not read grammar file: %s\n", schannel->name, filename); status = SWITCH_STATUS_FALSE; goto done; } grammar_file_size = switch_file_get_size(grammar_file); if (grammar_file_size == 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Grammar file is empty: %s\n", schannel->name, filename); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Grammar file is empty: %s\n", schannel->name, filename); status = SWITCH_STATUS_FALSE; goto done; } grammar_file_data = (char *) switch_core_alloc(schannel->memory_pool, grammar_file_size + 1); to_read = grammar_file_size; if (switch_file_read(grammar_file, grammar_file_data, &to_read) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Grammar file read error: %s\n", schannel->name, filename); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Grammar file read error: %s\n", schannel->name, filename); status = SWITCH_STATUS_FALSE; goto done; } if (to_read != grammar_file_size) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Could not read entire grammar file: %s\n", schannel->name, filename); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Could not read entire grammar file: %s\n", schannel->name, filename); status = SWITCH_STATUS_FALSE; goto done; } @@ -3244,12 +3274,12 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha } else if (text_starts_with(grammar_data, JSGF_ID)) { type = GRAMMAR_TYPE_JSGF; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to determine grammar type: %s\n", schannel->name, grammar_data); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) unable to determine grammar type: %s\n", schannel->name, grammar_data); status = SWITCH_STATUS_FALSE; goto done; } } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar is %s\n", schannel->name, grammar_type_to_mime(type, schannel->profile)); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) grammar is %s\n", schannel->name, grammar_type_to_mime(type, schannel->profile)); /* load the grammar */ if (recog_channel_load_grammar(schannel, name, type, grammar_data) != SWITCH_STATUS_SUCCESS) { @@ -3410,19 +3440,19 @@ static switch_status_t recog_asr_feed_dtmf(switch_asr_handle_t *ah, const switch if (!r->dtmf_generator) { if (!r->unimrcp_stream) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Cannot queue DTMF: No UniMRCP stream object open\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Cannot queue DTMF: No UniMRCP stream object open\n", schannel->name); return SWITCH_STATUS_FALSE; } r->dtmf_generator = mpf_dtmf_generator_create(r->unimrcp_stream, schannel->unimrcp_session->pool); if (!r->dtmf_generator) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Cannot queue DTMF: Failed to create DTMF generator\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Cannot queue DTMF: Failed to create DTMF generator\n", schannel->name); return SWITCH_STATUS_FALSE; } } digits[0] = dtmf->digit; digits[1] = '\0'; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Queued DTMF: %s\n", schannel->name, digits); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Queued DTMF: %s\n", schannel->name, digits); mpf_dtmf_generator_enqueue(r->dtmf_generator, digits); r->dtmf_generator_active = 1; @@ -3569,24 +3599,24 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp /* received the response to RECOGNIZE request */ if (message->start_line.request_state == MRCP_REQUEST_STATE_INPROGRESS) { /* RECOGNIZE in progress */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE IN PROGRESS\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) RECOGNIZE IN PROGRESS\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_PROCESSING); } else if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) { /* RECOGNIZE failed to start */ if (!recog_hdr || recog_hdr->completion_cause == RECOGNIZER_COMPLETION_CAUSE_UNKNOWN) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d\n", schannel->name, message->start_line.status_code); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d, completion-cause = %03d\n", + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d, completion-cause = %03d\n", schannel->name, message->start_line.status_code, recog_hdr->completion_cause); } speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } else if (message->start_line.request_state == MRCP_REQUEST_STATE_PENDING) { /* RECOGNIZE is queued */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE PENDING\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) RECOGNIZE PENDING\n", schannel->name); } else { /* received unexpected request_state */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected RECOGNIZE request state: %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected RECOGNIZE request state: %d\n", schannel->name, message->start_line.request_state); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } @@ -3594,11 +3624,11 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp /* received response to the STOP request */ if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) { /* got COMPLETE */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE STOPPED\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) RECOGNIZE STOPPED\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_READY); } else { /* received unexpected request state */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP request state: %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected STOP request state: %d\n", schannel->name, message->start_line.request_state); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } @@ -3606,10 +3636,10 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp /* received response to START-INPUT-TIMERS request */ if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) { if (message->start_line.status_code >= 200 && message->start_line.status_code <= 299) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) timers started\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) timers started\n", schannel->name); recog_channel_set_timers_started(schannel); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) timers failed to start, status code = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) timers failed to start, status code = %d\n", schannel->name, message->start_line.status_code); } } @@ -3617,24 +3647,24 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp /* received response to DEFINE-GRAMMAR request */ if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) { if (message->start_line.status_code >= 200 && message->start_line.status_code <= 299) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar loaded\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) grammar loaded\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_READY); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar failed to load, status code = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) grammar failed to load, status code = %d\n", schannel->name, message->start_line.status_code); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } } } else { /* received unexpected response */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name, (int) message->start_line.method_id); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } } else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) { /* received MRCP event */ if (message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNITION COMPLETE, Completion-Cause: %03d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) RECOGNITION COMPLETE, Completion-Cause: %03d\n", schannel->name, recog_hdr->completion_cause); if (message->body.length > 0) { if (message->body.buf[message->body.length - 1] == '\0') { @@ -3652,22 +3682,22 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp } } else { char *completion_cause = switch_mprintf("Completion-Cause: %03d", recog_hdr->completion_cause); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) No result\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) No result\n", schannel->name); recog_channel_set_result_headers(schannel, recog_hdr); recog_channel_set_results(schannel, completion_cause); switch_safe_free(completion_cause); } speech_channel_set_state(schannel, SPEECH_CHANNEL_READY); } else if (message->start_line.method_id == RECOGNIZER_START_OF_INPUT) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) START OF INPUT\n", schannel->name); + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) START OF INPUT\n", schannel->name); recog_channel_set_start_of_input(schannel); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name, (int) message->start_line.method_id); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name, + switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name, message->start_line.message_type); speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR); } @@ -4072,18 +4102,24 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) } client = mrcp_client_create(dir_layout); if (!client) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create MRCP client\n"); goto done; } pool = mrcp_client_memory_pool_get(client); if (!pool) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to get MRCP client memory pool\n"); client = NULL; goto done; } /* load the synthesizer and recognizer resources */ resource_loader = mrcp_resource_loader_create(FALSE, pool); - if (resource_loader) { + if (!resource_loader) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create MRCP resource loader\n"); + client = NULL; + goto done; + } else { apt_str_t synth_resource; apt_str_t recog_resource; apt_string_set(&synth_resource, "speechsynth"); @@ -4092,17 +4128,21 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) mrcp_resource_load(resource_loader, &recog_resource); resource_factory = mrcp_resource_factory_get(resource_loader); mrcp_client_resource_factory_register(client, resource_factory); - } else { + } + + codec_manager = mpf_engine_codec_manager_create(pool); + if (!codec_manager) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create MPF codec manager\n"); + client = NULL; + goto done; + } + if (!mrcp_client_codec_manager_register(client, codec_manager)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create register MRCP client codec manager\n"); client = NULL; goto done; } - codec_manager = mpf_engine_codec_manager_create(pool); - if (codec_manager) { - mrcp_client_codec_manager_register(client, codec_manager); - } - - /* set up MRCPv2 connection agent that will be shared with all profiles */ + /* set up MRCP connection agent that will be shared with all profiles */ if (!zstr(globals.unimrcp_max_connection_count)) { max_connection_count = atoi(globals.unimrcp_max_connection_count); } @@ -4113,20 +4153,51 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) offer_new_connection = strcasecmp("true", globals.unimrcp_offer_new_connection); } connection_agent = mrcp_client_connection_agent_create("MRCPv2ConnectionAgent", max_connection_count, offer_new_connection, pool); - if (connection_agent) { - if (!zstr(globals.unimrcp_request_timeout)) { - apr_size_t request_timeout = (apr_size_t)atol(globals.unimrcp_request_timeout); - if (request_timeout > 0) { - mrcp_client_connection_timeout_set(connection_agent, request_timeout); - } + if (!connection_agent) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create MRCP connection agent\n"); + client = NULL; + goto done; + } + if (!zstr(globals.unimrcp_rx_buffer_size)) { + apr_size_t rx_buffer_size = (apr_size_t)atol(globals.unimrcp_rx_buffer_size); + if (rx_buffer_size > 0) { + mrcp_client_connection_rx_size_set(connection_agent, rx_buffer_size); } - mrcp_client_connection_agent_register(client, connection_agent); + } + if (!zstr(globals.unimrcp_tx_buffer_size)) { + apr_size_t tx_buffer_size = (apr_size_t)atol(globals.unimrcp_tx_buffer_size); + if (tx_buffer_size > 0) { + mrcp_client_connection_tx_size_set(connection_agent, tx_buffer_size); + } + } + if (!zstr(globals.unimrcp_request_timeout)) { + apr_size_t request_timeout = (apr_size_t)atol(globals.unimrcp_request_timeout); + if (request_timeout > 0) { + mrcp_client_connection_timeout_set(connection_agent, request_timeout); + } + } + if (!mrcp_client_connection_agent_register(client, connection_agent)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create register MRCP connection agent\n"); + client = NULL; + goto done; } /* Set up the media engine that will be shared with all profiles */ media_engine = mpf_engine_create("MediaEngine", pool); - if (media_engine) { - mrcp_client_media_engine_register(client, media_engine); + if (!media_engine) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create MPF media engine\n"); + client = NULL; + goto done; + } + if (!mpf_engine_scheduler_rate_set(media_engine, 1)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to set MPF engine scheduler rate\n"); + client = NULL; + goto done; + } + if (!mrcp_client_media_engine_register(client, media_engine)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to register MPF media engine\n"); + client = NULL; + goto done; } /* configure the client profiles */ @@ -4146,6 +4217,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) mrcp_sig_settings_t *sig_settings = mrcp_signaling_settings_alloc(pool); profile_t *mod_profile = NULL; switch_xml_t default_params = NULL; + mrcp_connection_agent_t *v2_profile_connection_agent = NULL; /* get profile attributes */ const char *name = apr_pstrdup(pool, switch_xml_attr(profile, "name")); @@ -4218,6 +4290,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) rtsp_client_config_t *config = mrcp_unirtsp_client_config_alloc(pool); config->origin = DEFAULT_SDP_ORIGIN; sig_settings->resource_location = DEFAULT_RESOURCE_LOCATION; + v2_profile_connection_agent = NULL; if (!zstr(globals.unimrcp_request_timeout)) { apr_size_t request_timeout = (apr_size_t)atol(globals.unimrcp_request_timeout); @@ -4238,10 +4311,15 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) if (!process_mrcpv1_config(config, sig_settings, param_name, param_value, pool) && !process_rtp_config(client, rtp_config, rtp_settings, param_name, param_value, pool) && !process_profile_config(mod_profile, param_name, param_value, mod_pool)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown param %s\n", param_name); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring unknown param %s\n", param_name); } } agent = mrcp_unirtsp_client_agent_create(name, config, pool); + if (!agent) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create MRCP RTSP client agent\n"); + client = NULL; + goto done; + } } else if (strcmp("2", version) == 0) { /* MRCPv2 configuration */ mrcp_sofia_client_config_t *config = mrcp_sofiasip_client_config_alloc(pool); @@ -4253,6 +4331,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) config->ext_ip = NULL; config->user_agent_name = DEFAULT_SOFIASIP_UA_NAME; config->origin = DEFAULT_SDP_ORIGIN; + v2_profile_connection_agent = connection_agent; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading MRCPv2 profile: %s\n", name); for (param = switch_xml_child(profile, "param"); param; param = switch_xml_next(param)) { const char *param_name = switch_xml_attr(param, "name"); @@ -4266,10 +4345,15 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) if (!process_mrcpv2_config(config, sig_settings, param_name, param_value, pool) && !process_rtp_config(client, rtp_config, rtp_settings, param_name, param_value, pool) && !process_profile_config(mod_profile, param_name, param_value, mod_pool)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown param %s\n", param_name); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring unknown param %s\n", param_name); } } agent = mrcp_sofiasip_client_agent_create(name, config, pool); + if (!agent) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create MRCP SIP client agent\n"); + client = NULL; + goto done; + } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "version must be either \"1\" or \"2\"\n"); client = NULL; @@ -4277,18 +4361,24 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) } termination_factory = mpf_rtp_termination_factory_create(rtp_config, pool); - if (termination_factory) { - mrcp_client_rtp_factory_register(client, termination_factory, name); - } - if (agent) { - mrcp_client_signaling_agent_register(client, agent); + if (!termination_factory) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create RTP termination factory\n"); + client = NULL; + goto done; } + mrcp_client_rtp_factory_register(client, termination_factory, name); + mrcp_client_rtp_settings_register(client, rtp_settings, "RTP-Settings"); + mrcp_client_signaling_settings_register(client, sig_settings, "Signaling-Settings"); + mrcp_client_signaling_agent_register(client, agent); /* create the profile and register it */ - mprofile = mrcp_client_profile_create(NULL, agent, connection_agent, media_engine, termination_factory, rtp_settings, sig_settings, pool); - if (mprofile) { - mrcp_client_profile_register(client, mprofile, name); + mprofile = mrcp_client_profile_create(NULL, agent, v2_profile_connection_agent, media_engine, termination_factory, rtp_settings, sig_settings, pool); + if (!mprofile) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create MRCP client profile\n"); + client = NULL; + goto done; } + mrcp_client_profile_register(client, mprofile, name); } } From 1e926198fab716d62956b8c03aca753eb4d6abe7 Mon Sep 17 00:00:00 2001 From: "E. Schmidbauer" Date: Tue, 18 Nov 2014 15:42:44 -0500 Subject: [PATCH 04/10] FS-6097 - added fifo_position macro --- conf/vanilla/lang/en/ivr/sounds.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/conf/vanilla/lang/en/ivr/sounds.xml b/conf/vanilla/lang/en/ivr/sounds.xml index 0c4f0b9c70..9de7fa4eb7 100644 --- a/conf/vanilla/lang/en/ivr/sounds.xml +++ b/conf/vanilla/lang/en/ivr/sounds.xml @@ -1,4 +1,14 @@ + + + + + + + + + + From da6043f353a73999951a586dc651267c747e39ae Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 13 Nov 2014 20:51:53 -0600 Subject: [PATCH 05/10] improve timerfd implementation to be more accurate --- src/switch_time.c | 98 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/src/switch_time.c b/src/switch_time.c index ec4e9d48b7..dc3fe50303 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -132,7 +132,7 @@ struct timer_private { typedef struct timer_private timer_private_t; struct timer_matrix { - switch_size_t tick; + uint64_t tick; uint32_t count; uint32_t roll; switch_mutex_t *mutex; @@ -385,23 +385,34 @@ SWITCH_DECLARE(void) switch_time_set_cond_yield(switch_bool_t enable) switch_time_sync(); } +static switch_status_t timer_generic_sync(switch_timer_t *timer) +{ + switch_time_t now = time_now(0); + int64_t elapsed = (now - timer->start); + + timer->tick = (elapsed / timer->interval) / 1000; + timer->samplecount = timer->tick * timer->samples; + + return SWITCH_STATUS_SUCCESS; +} + + + ///////// #ifdef HAVE_TIMERFD_CREATE #define MAX_INTERVAL 2000 /* ms */ struct interval_timer { - int fd; - switch_size_t tick; + int fd; }; typedef struct interval_timer interval_timer_t; static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval) { struct itimerspec val; - int fd; - - it->tick = 0; + int fd, r; + uint64_t exp; fd = timerfd_create(CLOCK_MONOTONIC, 0); @@ -409,17 +420,23 @@ static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval return SWITCH_STATUS_GENERR; } - val.it_interval.tv_sec = interval / 1000; - val.it_interval.tv_nsec = (interval % 1000) * 1000000; + val.it_interval.tv_sec = 0; + val.it_interval.tv_nsec = interval * 1000000; val.it_value.tv_sec = 0; - val.it_value.tv_nsec = 100000; + val.it_value.tv_nsec = val.it_interval.tv_nsec; - if (timerfd_settime(fd, 0, &val, NULL) < 0) { + if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &val, NULL) < 0) { + close(fd); + return SWITCH_STATUS_GENERR; + } + + if ((r = read(fd, &exp, sizeof(exp)) < 0)) { close(fd); return SWITCH_STATUS_GENERR; } it->fd = fd; + return SWITCH_STATUS_SUCCESS; } @@ -439,7 +456,9 @@ static switch_status_t _timerfd_init(switch_timer_t *timer) return SWITCH_STATUS_GENERR; it = switch_core_alloc(timer->memory_pool, sizeof(*it)); + if ((rc = timerfd_start_interval(it, timer->interval)) == SWITCH_STATUS_SUCCESS) { + timer->start = time_now(0); timer->private_info = it; } @@ -457,34 +476,27 @@ static switch_status_t _timerfd_step(switch_timer_t *timer) static switch_status_t _timerfd_next(switch_timer_t *timer) { interval_timer_t *it = timer->private_info; - uint64_t x, u64 = 0; + uint64_t u64 = 0; if (read(it->fd, &u64, sizeof(u64)) < 0) { return SWITCH_STATUS_GENERR; } else { - for (x = 0; x < u64; x++) { - it->tick++; - _timerfd_step(timer); - } + timer->tick += u64; + timer->samplecount = timer->tick * timer->samples; } return SWITCH_STATUS_SUCCESS; } -static switch_status_t _timerfd_sync(switch_timer_t *timer) -{ - interval_timer_t *it = timer->private_info; - - timer->tick = it->tick; - - return SWITCH_STATUS_SUCCESS; -} - static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step) { interval_timer_t *it = timer->private_info; - int diff = (int)(timer->tick - it->tick); + struct itimerspec val; + int diff; + timerfd_gettime(it->fd, &val); + diff = val.it_interval.tv_nsec / 1000; + if (diff > 0) { /* still pending */ timer->diff = diff; @@ -676,6 +688,15 @@ static switch_status_t timer_init(switch_timer_t *timer) timer_private_t *private_info; int sanity = 0; + timer->start = time_now(0); + + if (timer->interval == 1) { + switch_mutex_lock(globals.mutex); + globals.timer_count++; + switch_mutex_unlock(globals.mutex); + return SWITCH_STATUS_SUCCESS; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_init(timer); @@ -743,6 +764,10 @@ static switch_status_t timer_step(switch_timer_t *timer) timer_private_t *private_info; uint64_t samples; + if (timer->interval == 1) { + return SWITCH_STATUS_FALSE; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_step(timer); @@ -773,9 +798,13 @@ static switch_status_t timer_sync(switch_timer_t *timer) { timer_private_t *private_info; + if (timer->interval == 1) { + return timer_generic_sync(timer); + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { - return _timerfd_sync(timer); + return timer_generic_sync(timer); } #endif @@ -806,6 +835,10 @@ static switch_status_t timer_next(switch_timer_t *timer) #endif int delta; + if (timer->interval == 1) { + return SWITCH_STATUS_FALSE; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_next(timer); @@ -859,6 +892,10 @@ static switch_status_t timer_check(switch_timer_t *timer, switch_bool_t step) timer_private_t *private_info; switch_status_t status = SWITCH_STATUS_SUCCESS; + if (timer->interval == 1) { + return SWITCH_STATUS_FALSE; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_check(timer, step); @@ -895,6 +932,15 @@ static switch_status_t timer_destroy(switch_timer_t *timer) { timer_private_t *private_info; + if (timer->interval == 1) { + switch_mutex_lock(globals.mutex); + if (globals.timer_count) { + globals.timer_count--; + } + switch_mutex_unlock(globals.mutex); + return SWITCH_STATUS_SUCCESS; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_destroy(timer); From 878a04715ae801ccd9587249240f5a6e4f16dd0e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 18 Nov 2014 17:00:44 -0600 Subject: [PATCH 06/10] revert --- src/switch_time.c | 98 +++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 72 deletions(-) diff --git a/src/switch_time.c b/src/switch_time.c index dc3fe50303..ec4e9d48b7 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -132,7 +132,7 @@ struct timer_private { typedef struct timer_private timer_private_t; struct timer_matrix { - uint64_t tick; + switch_size_t tick; uint32_t count; uint32_t roll; switch_mutex_t *mutex; @@ -385,34 +385,23 @@ SWITCH_DECLARE(void) switch_time_set_cond_yield(switch_bool_t enable) switch_time_sync(); } -static switch_status_t timer_generic_sync(switch_timer_t *timer) -{ - switch_time_t now = time_now(0); - int64_t elapsed = (now - timer->start); - - timer->tick = (elapsed / timer->interval) / 1000; - timer->samplecount = timer->tick * timer->samples; - - return SWITCH_STATUS_SUCCESS; -} - - - ///////// #ifdef HAVE_TIMERFD_CREATE #define MAX_INTERVAL 2000 /* ms */ struct interval_timer { - int fd; + int fd; + switch_size_t tick; }; typedef struct interval_timer interval_timer_t; static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval) { struct itimerspec val; - int fd, r; - uint64_t exp; + int fd; + + it->tick = 0; fd = timerfd_create(CLOCK_MONOTONIC, 0); @@ -420,23 +409,17 @@ static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval return SWITCH_STATUS_GENERR; } - val.it_interval.tv_sec = 0; - val.it_interval.tv_nsec = interval * 1000000; + val.it_interval.tv_sec = interval / 1000; + val.it_interval.tv_nsec = (interval % 1000) * 1000000; val.it_value.tv_sec = 0; - val.it_value.tv_nsec = val.it_interval.tv_nsec; + val.it_value.tv_nsec = 100000; - if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &val, NULL) < 0) { - close(fd); - return SWITCH_STATUS_GENERR; - } - - if ((r = read(fd, &exp, sizeof(exp)) < 0)) { + if (timerfd_settime(fd, 0, &val, NULL) < 0) { close(fd); return SWITCH_STATUS_GENERR; } it->fd = fd; - return SWITCH_STATUS_SUCCESS; } @@ -456,9 +439,7 @@ static switch_status_t _timerfd_init(switch_timer_t *timer) return SWITCH_STATUS_GENERR; it = switch_core_alloc(timer->memory_pool, sizeof(*it)); - if ((rc = timerfd_start_interval(it, timer->interval)) == SWITCH_STATUS_SUCCESS) { - timer->start = time_now(0); timer->private_info = it; } @@ -476,27 +457,34 @@ static switch_status_t _timerfd_step(switch_timer_t *timer) static switch_status_t _timerfd_next(switch_timer_t *timer) { interval_timer_t *it = timer->private_info; - uint64_t u64 = 0; + uint64_t x, u64 = 0; if (read(it->fd, &u64, sizeof(u64)) < 0) { return SWITCH_STATUS_GENERR; } else { - timer->tick += u64; - timer->samplecount = timer->tick * timer->samples; + for (x = 0; x < u64; x++) { + it->tick++; + _timerfd_step(timer); + } } return SWITCH_STATUS_SUCCESS; } +static switch_status_t _timerfd_sync(switch_timer_t *timer) +{ + interval_timer_t *it = timer->private_info; + + timer->tick = it->tick; + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step) { interval_timer_t *it = timer->private_info; - struct itimerspec val; - int diff; + int diff = (int)(timer->tick - it->tick); - timerfd_gettime(it->fd, &val); - diff = val.it_interval.tv_nsec / 1000; - if (diff > 0) { /* still pending */ timer->diff = diff; @@ -688,15 +676,6 @@ static switch_status_t timer_init(switch_timer_t *timer) timer_private_t *private_info; int sanity = 0; - timer->start = time_now(0); - - if (timer->interval == 1) { - switch_mutex_lock(globals.mutex); - globals.timer_count++; - switch_mutex_unlock(globals.mutex); - return SWITCH_STATUS_SUCCESS; - } - #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_init(timer); @@ -764,10 +743,6 @@ static switch_status_t timer_step(switch_timer_t *timer) timer_private_t *private_info; uint64_t samples; - if (timer->interval == 1) { - return SWITCH_STATUS_FALSE; - } - #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_step(timer); @@ -798,13 +773,9 @@ static switch_status_t timer_sync(switch_timer_t *timer) { timer_private_t *private_info; - if (timer->interval == 1) { - return timer_generic_sync(timer); - } - #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { - return timer_generic_sync(timer); + return _timerfd_sync(timer); } #endif @@ -835,10 +806,6 @@ static switch_status_t timer_next(switch_timer_t *timer) #endif int delta; - if (timer->interval == 1) { - return SWITCH_STATUS_FALSE; - } - #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_next(timer); @@ -892,10 +859,6 @@ static switch_status_t timer_check(switch_timer_t *timer, switch_bool_t step) timer_private_t *private_info; switch_status_t status = SWITCH_STATUS_SUCCESS; - if (timer->interval == 1) { - return SWITCH_STATUS_FALSE; - } - #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_check(timer, step); @@ -932,15 +895,6 @@ static switch_status_t timer_destroy(switch_timer_t *timer) { timer_private_t *private_info; - if (timer->interval == 1) { - switch_mutex_lock(globals.mutex); - if (globals.timer_count) { - globals.timer_count--; - } - switch_mutex_unlock(globals.mutex); - return SWITCH_STATUS_SUCCESS; - } - #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_destroy(timer); From df423b88d64854f908849b254b1879c149ca5791 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 13 Nov 2014 20:51:53 -0600 Subject: [PATCH 07/10] improve timerfd implementation to be more accurate --- src/include/switch_module_interfaces.h | 3 +- src/switch_time.c | 98 +++++++++++++++++++------- 2 files changed, 74 insertions(+), 27 deletions(-) diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 0f4eebf239..e70e663dd9 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -215,7 +215,8 @@ struct switch_timer { void *private_info; /*! remaining time from last call to _check() */ switch_size_t diff; - switch_size_t tick; + switch_time_t start; + uint64_t tick; }; typedef enum { diff --git a/src/switch_time.c b/src/switch_time.c index ec4e9d48b7..dc3fe50303 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -132,7 +132,7 @@ struct timer_private { typedef struct timer_private timer_private_t; struct timer_matrix { - switch_size_t tick; + uint64_t tick; uint32_t count; uint32_t roll; switch_mutex_t *mutex; @@ -385,23 +385,34 @@ SWITCH_DECLARE(void) switch_time_set_cond_yield(switch_bool_t enable) switch_time_sync(); } +static switch_status_t timer_generic_sync(switch_timer_t *timer) +{ + switch_time_t now = time_now(0); + int64_t elapsed = (now - timer->start); + + timer->tick = (elapsed / timer->interval) / 1000; + timer->samplecount = timer->tick * timer->samples; + + return SWITCH_STATUS_SUCCESS; +} + + + ///////// #ifdef HAVE_TIMERFD_CREATE #define MAX_INTERVAL 2000 /* ms */ struct interval_timer { - int fd; - switch_size_t tick; + int fd; }; typedef struct interval_timer interval_timer_t; static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval) { struct itimerspec val; - int fd; - - it->tick = 0; + int fd, r; + uint64_t exp; fd = timerfd_create(CLOCK_MONOTONIC, 0); @@ -409,17 +420,23 @@ static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval return SWITCH_STATUS_GENERR; } - val.it_interval.tv_sec = interval / 1000; - val.it_interval.tv_nsec = (interval % 1000) * 1000000; + val.it_interval.tv_sec = 0; + val.it_interval.tv_nsec = interval * 1000000; val.it_value.tv_sec = 0; - val.it_value.tv_nsec = 100000; + val.it_value.tv_nsec = val.it_interval.tv_nsec; - if (timerfd_settime(fd, 0, &val, NULL) < 0) { + if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &val, NULL) < 0) { + close(fd); + return SWITCH_STATUS_GENERR; + } + + if ((r = read(fd, &exp, sizeof(exp)) < 0)) { close(fd); return SWITCH_STATUS_GENERR; } it->fd = fd; + return SWITCH_STATUS_SUCCESS; } @@ -439,7 +456,9 @@ static switch_status_t _timerfd_init(switch_timer_t *timer) return SWITCH_STATUS_GENERR; it = switch_core_alloc(timer->memory_pool, sizeof(*it)); + if ((rc = timerfd_start_interval(it, timer->interval)) == SWITCH_STATUS_SUCCESS) { + timer->start = time_now(0); timer->private_info = it; } @@ -457,34 +476,27 @@ static switch_status_t _timerfd_step(switch_timer_t *timer) static switch_status_t _timerfd_next(switch_timer_t *timer) { interval_timer_t *it = timer->private_info; - uint64_t x, u64 = 0; + uint64_t u64 = 0; if (read(it->fd, &u64, sizeof(u64)) < 0) { return SWITCH_STATUS_GENERR; } else { - for (x = 0; x < u64; x++) { - it->tick++; - _timerfd_step(timer); - } + timer->tick += u64; + timer->samplecount = timer->tick * timer->samples; } return SWITCH_STATUS_SUCCESS; } -static switch_status_t _timerfd_sync(switch_timer_t *timer) -{ - interval_timer_t *it = timer->private_info; - - timer->tick = it->tick; - - return SWITCH_STATUS_SUCCESS; -} - static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step) { interval_timer_t *it = timer->private_info; - int diff = (int)(timer->tick - it->tick); + struct itimerspec val; + int diff; + timerfd_gettime(it->fd, &val); + diff = val.it_interval.tv_nsec / 1000; + if (diff > 0) { /* still pending */ timer->diff = diff; @@ -676,6 +688,15 @@ static switch_status_t timer_init(switch_timer_t *timer) timer_private_t *private_info; int sanity = 0; + timer->start = time_now(0); + + if (timer->interval == 1) { + switch_mutex_lock(globals.mutex); + globals.timer_count++; + switch_mutex_unlock(globals.mutex); + return SWITCH_STATUS_SUCCESS; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_init(timer); @@ -743,6 +764,10 @@ static switch_status_t timer_step(switch_timer_t *timer) timer_private_t *private_info; uint64_t samples; + if (timer->interval == 1) { + return SWITCH_STATUS_FALSE; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_step(timer); @@ -773,9 +798,13 @@ static switch_status_t timer_sync(switch_timer_t *timer) { timer_private_t *private_info; + if (timer->interval == 1) { + return timer_generic_sync(timer); + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { - return _timerfd_sync(timer); + return timer_generic_sync(timer); } #endif @@ -806,6 +835,10 @@ static switch_status_t timer_next(switch_timer_t *timer) #endif int delta; + if (timer->interval == 1) { + return SWITCH_STATUS_FALSE; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_next(timer); @@ -859,6 +892,10 @@ static switch_status_t timer_check(switch_timer_t *timer, switch_bool_t step) timer_private_t *private_info; switch_status_t status = SWITCH_STATUS_SUCCESS; + if (timer->interval == 1) { + return SWITCH_STATUS_FALSE; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_check(timer, step); @@ -895,6 +932,15 @@ static switch_status_t timer_destroy(switch_timer_t *timer) { timer_private_t *private_info; + if (timer->interval == 1) { + switch_mutex_lock(globals.mutex); + if (globals.timer_count) { + globals.timer_count--; + } + switch_mutex_unlock(globals.mutex); + return SWITCH_STATUS_SUCCESS; + } + #ifdef HAVE_TIMERFD_CREATE if (TFD == 2) { return _timerfd_destroy(timer); From 9673cf0acbd7591ce64b46385391dd7feac4c036 Mon Sep 17 00:00:00 2001 From: Richard Neese Date: Wed, 19 Nov 2014 14:00:12 -0600 Subject: [PATCH 08/10] Fix for apr build issue fs-6848 freebsd arm --- libs/apr/include/apr_general.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/apr/include/apr_general.h b/libs/apr/include/apr_general.h index db1f25bc81..b8c4eec7bd 100644 --- a/libs/apr/include/apr_general.h +++ b/libs/apr/include/apr_general.h @@ -76,7 +76,7 @@ typedef int apr_signum_t; * @return offset */ -#if defined(CRAY) || (defined(__arm) && !defined(LINUX)) +#if defined(CRAY) || (defined(__arm) && !defined(LINUX) || defined(__FreeBSD__))) #ifdef __STDC__ #define APR_OFFSET(p_type,field) _Offsetof(p_type,field) #else From 62a2e10e4137c443cf7d199f98443b50f6351ef9 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 19 Nov 2014 16:06:42 -0500 Subject: [PATCH 09/10] remove hack breaking some cross compile builds. if you really need this, you should be using new enough glibc anyways --- Makefile.am | 4 - configure.ac | 4 - src/include/timerfd_wrap.h | 93 ------------------------ src/mod/timers/mod_timerfd/mod_timerfd.c | 5 -- src/switch_time.c | 7 -- 5 files changed, 113 deletions(-) delete mode 100644 src/include/timerfd_wrap.h diff --git a/Makefile.am b/Makefile.am index 886c5edf63..96e9181646 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,10 +141,6 @@ if HAVE_ODBC CORE_CFLAGS += -DSWITCH_HAVE_ODBC $(ODBC_INC_FLAGS) endif -if ENABLE_TIMERFD_WRAPPER -CORE_CFLAGS += -DTIMERFD_WRAP -endif - ## ## libfreeswitch ## diff --git a/configure.ac b/configure.ac index a11de35c84..a91690aeca 100644 --- a/configure.ac +++ b/configure.ac @@ -630,10 +630,6 @@ if test x"$enable_deprecated_core_db_events" = x"yes" ; then AC_DEFINE([SWITCH_DEPRECATED_CORE_DB], [1], [Define to 1 to enable deprecated core db events]) fi -AC_ARG_ENABLE(timerfd-wrapper, -[AC_HELP_STRING([--enable-timerfd-wrapper],[timerfd is in the kernel but not in your libc])],[enable_timer_fd_wrapper="$enableval"],[enable_timer_fd_wrapper="no"]) -AM_CONDITIONAL([ENABLE_TIMERFD_WRAPPER],[test "x$enable_timer_fd_wrapper" != "xno"]) - ESL_LDFLAGS= PLATFORM_CORE_LDFLAGS= PLATFORM_CORE_LIBS= diff --git a/src/include/timerfd_wrap.h b/src/include/timerfd_wrap.h deleted file mode 100644 index bdcd11b4f1..0000000000 --- a/src/include/timerfd_wrap.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Anthony Minessale II - * - * timerfd_wrap.h -- timerfd syscall wrapper - * - */ -/*! \file timerfd_wrap.h - \brief timerfd syscall wrapper -*/ - -#ifndef TIMERFD_WRAP_H -#define TIMERFD_WRAP_H -SWITCH_BEGIN_EXTERN_C - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifndef __NR_timerfd -#if defined(__x86_64__) -#define __NR_timerfd_create 283 -#define __NR_timerfd_settime 286 -#define __NR_timerfd_gettime 287 -#elif defined(__i386__) -#define __NR_timerfd_create 322 -#define __NR_timerfd_settime 325 -#define __NR_timerfd_gettime 326 -#else -#error invalid system -#endif -#endif - -#define TFD_TIMER_ABSTIME (1 << 0) - -int timerfd_create(int clockid, int flags) -{ - - return syscall(__NR_timerfd_create, clockid, flags); -} - -int timerfd_settime(int ufc, int flags, const struct itimerspec *utmr, struct itimerspec *otmr) -{ - - return syscall(__NR_timerfd_settime, ufc, flags, utmr, otmr); -} - -int timerfd_gettime(int ufc, struct itimerspec *otmr) -{ - - return syscall(__NR_timerfd_gettime, ufc, otmr); -} - -SWITCH_END_EXTERN_C - -#endif diff --git a/src/mod/timers/mod_timerfd/mod_timerfd.c b/src/mod/timers/mod_timerfd/mod_timerfd.c index 0eafab5e48..bd07be8cdd 100644 --- a/src/mod/timers/mod_timerfd/mod_timerfd.c +++ b/src/mod/timers/mod_timerfd/mod_timerfd.c @@ -31,12 +31,7 @@ */ #include -#ifdef TIMERFD_WRAP -#define TFD_CLOEXEC 0 -#include -#else #include -#endif #include SWITCH_MODULE_LOAD_FUNCTION(mod_timerfd_load); diff --git a/src/switch_time.c b/src/switch_time.c index dc3fe50303..cc5fbe8dbe 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -35,16 +35,9 @@ #include #include "private/switch_core_pvt.h" -#ifdef TIMERFD_WRAP -#include -#ifndef HAVE_TIMERFD_CREATE -#define HAVE_TIMERFD_CREATE -#endif -#else #ifdef HAVE_TIMERFD_CREATE #include #endif -#endif //#if defined(DARWIN) #define DISABLE_1MS_COND From c645ab3889925cb8a4023be20cfbc81e8ffdf33c Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Wed, 19 Nov 2014 16:05:40 -0600 Subject: [PATCH 10/10] FS-6848 #resolve #comment slight tweak to fix the logic and avoid unbalanced parens --- libs/apr/include/apr_general.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/apr/include/apr_general.h b/libs/apr/include/apr_general.h index b8c4eec7bd..42eec83ce4 100644 --- a/libs/apr/include/apr_general.h +++ b/libs/apr/include/apr_general.h @@ -76,7 +76,7 @@ typedef int apr_signum_t; * @return offset */ -#if defined(CRAY) || (defined(__arm) && !defined(LINUX) || defined(__FreeBSD__))) +#if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__FreeBSD__))) #ifdef __STDC__ #define APR_OFFSET(p_type,field) _Offsetof(p_type,field) #else