<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14260] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14260">14260</a></dd>
<dt>Author</dt> <dd>mikej</dd>
<dt>Date</dt> <dd>2009-07-15 15:30:39 -0500 (Wed, 15 Jul 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>commit 027047ed7b07832456cd5d13f4c85da24aca26b5
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Tue Jul 14 18:17:37 2009 +0000
Added missing UNIMRCP_APU_INCLUDES in pkg-config files
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1054 f001bc3a-424a-0410-80a0-a715b8f413a8
commit b0e1c8251f8039a8a22662120e5a362340733a9e
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Mon Jul 13 17:25:34 2009 +0000
if state != RECOGNIZING, there is nothing to do on deactivation
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1053 f001bc3a-424a-0410-80a0-a715b8f413a8
commit 3581b9d3ba59177f4aaced327e20b8dc53e234e3
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Mon Jul 13 16:14:38 2009 +0000
Do not include Completion-Cause header field in the IN-PROGRESS response sent by PocketSphinx plugin
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1052 f001bc3a-424a-0410-80a0-a715b8f413a8
commit 831f43f9071e491169d4d5a7e3d0cb2009c3af21
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Mon Jul 13 15:27:33 2009 +0000
Using MRCP_SESSION_SID(session) macro wherever session id is logged
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1051 f001bc3a-424a-0410-80a0-a715b8f413a8
commit 9349bd2b393ee0b300942bfa8cacc264687ecea9
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Sat Jul 11 15:17:42 2009 +0000
Sent async channel_open and channel_close responses
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1050 f001bc3a-424a-0410-80a0-a715b8f413a8
commit 5775dfc74e8fe982735da32dfa12dc05f0d20892
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Sat Jul 11 15:15:47 2009 +0000
Sent async channel_close response
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1049 f001bc3a-424a-0410-80a0-a715b8f413a8
commit efa4d10b2dc3de238dfb4a26b25ef3a580fb0bf0
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Sat Jul 11 12:54:47 2009 +0000
Enhanced state machine to STOP in-progress SPEAK or RECOGNIZE requests on session termination, thus guarantee there is no remaining request, when plugin cha
nnel_close() method is called.
channel_open() -> SPEAK -> STOP -> channel_close()
channel_open() -> SPEAK -> SPEAK-COMPLETE -> channel_close()
This allows to simplify implementation of plugins (nothing has to be changed).
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1048 f001bc3a-424a-0410-80a0-a715b8f413a8
commit aaf53907ea0705bc2a44fe785c8f7762e20e52cf
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Fri Jul 10 12:57:33 2009 +0000
Added utility function to get attributes of NLSML results such as confidence and grammar
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1047 f001bc3a-424a-0410-80a0-a715b8f413a8
commit f7c4dff83199cb9af8dc7ec6f121c384d2b6cea0
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Fri Jul 10 09:51:23 2009 +0000
Added missing includes for <stdlib.h> and <stdio.h> required on some platforms
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1046 f001bc3a-424a-0410-80a0-a715b8f413a8
commit 1cb7ccb6e63f4d34b6cfcbdc386446a36d052af1
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Thu Jul 9 19:05:18 2009 +0000
Using NLSML processor in demo
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1045 f001bc3a-424a-0410-80a0-a715b8f413a8
commit cd74eee440dd94cabe814c7d4f64dfef187b7445
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date: Thu Jul 9 18:52:49 2009 +0000
Added basic NLSML document processor
git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1044 f001bc3a-424a-0410-80a0-a715b8f413a8</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibsunimrcpbuildpkgconfigunimrcpclientpcin">freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in</a></li>
<li><a href="#freeswitchtrunklibsunimrcpbuildpkgconfigunimrcppluginpcin">freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in</a></li>
<li><a href="#freeswitchtrunklibsunimrcpbuildpkgconfigunimrcpserverpcin">freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsaprtoolkitMakefileam">freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/Makefile.am</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsaprtoolkitaprtoolkitvcproj">freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcproj</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpcontrolincludemrcp_resourceh">freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpcontrolincludemrcp_state_machineh">freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_state_machine.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcesincludemrcp_recog_state_machineh">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_state_machine.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcesincludemrcp_synth_state_machineh">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_state_machine.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_recog_client_state_machinec">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_client_state_machine.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_recog_headerc">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_recog_server_state_machinec">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_server_state_machine.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_synth_client_state_machinec">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_client_state_machine.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_synth_headerc">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_synth_server_state_machinec">freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_server_state_machine.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpserverincludemrcp_server_sessionh">freeswitch/trunk/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpserversrcmrcp_serverc">freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsmrcpserversrcmrcp_server_sessionc">freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcpmodulesmrcpsofiasipsrcmrcp_sdpc">freeswitch/trunk/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcpmodulesmrcpunirtspsrcmrcp_unirtsp_sdpc">freeswitch/trunk/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcpplatformslibunimrcpclientsrcunimrcp_clientc">freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcpplatformslibunimrcpserversrcunimrcp_serverc">freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcpplatformsunimrcpclientincludedemo_utilh">freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcpplatformsunimrcpclientsrcdemo_recog_applicationc">freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcpplatformsunimrcpclientsrcdemo_utilc">freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcppluginsmrcpflitesrcmrcp_flitec">freeswitch/trunk/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c</a></li>
<li><a href="#freeswitchtrunklibsunimrcppluginsmrcppocketsphinxsrcmrcp_pocketsphinxc">freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibsunimrcplibsaprtoolkitincludeapt_nlsml_doch">freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h</a></li>
<li><a href="#freeswitchtrunklibsunimrcplibsaprtoolkitsrcapt_nlsml_docc">freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunklibsunimrcpbuildpkgconfigunimrcpclientpcin"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpclient.pc.in        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> prefix=@prefix@
</span><span class="cx"> exec_prefix=@exec_prefix@
</span><span class="cx"> libdir=@libdir@
</span><del>-includedir=@includedir@ @UNIMRCP_APR_INCLUDES@
</del><ins>+includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ @UNIMRCP_APU_INCLUDES@
</ins><span class="cx">
</span><span class="cx"> Name: unimrcpclient
</span><span class="cx"> Description: UniMRCP Client Stack
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpbuildpkgconfigunimrcppluginpcin"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpplugin.pc.in        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> prefix=@prefix@
</span><span class="cx"> exec_prefix=@exec_prefix@
</span><span class="cx"> libdir=@libdir@
</span><del>-includedir=@includedir@ @UNIMRCP_APR_INCLUDES@
</del><ins>+includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ @UNIMRCP_APU_INCLUDES@
</ins><span class="cx">
</span><span class="cx"> Name: unimrcpplugin
</span><span class="cx"> Description: UniMRCP Server Plugin
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpbuildpkgconfigunimrcpserverpcin"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/build/pkgconfig/unimrcpserver.pc.in        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> prefix=@prefix@
</span><span class="cx"> exec_prefix=@exec_prefix@
</span><span class="cx"> libdir=@libdir@
</span><del>-includedir=@includedir@ @UNIMRCP_APR_INCLUDES@
</del><ins>+includedir=@includedir@ @UNIMRCP_APR_INCLUDES@ @UNIMRCP_APU_INCLUDES@
</ins><span class="cx">
</span><span class="cx"> Name: unimrcpserver
</span><span class="cx"> Description: UniMRCP Server Stack
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsaprtoolkitMakefileam"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/Makefile.am (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/Makefile.am        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/Makefile.am        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -21,6 +21,7 @@
</span><span class="cx"> include/apt_string_table.h \
</span><span class="cx"> include/apt_text_stream.h \
</span><span class="cx"> include/apt_net.h \
</span><ins>+ include/apt_nlsml_doc.h \
</ins><span class="cx"> include/apt_dir_layout.h \
</span><span class="cx"> include/apt_test_suite.h
</span><span class="cx">
</span><span class="lines">@@ -38,6 +39,7 @@
</span><span class="cx"> src/apt_string_table.c \
</span><span class="cx"> src/apt_text_stream.c \
</span><span class="cx"> src/apt_net.c \
</span><ins>+ src/apt_nlsml_doc.c \
</ins><span class="cx"> src/apt_dir_layout.c \
</span><span class="cx"> src/apt_test_suite.c
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsaprtoolkitaprtoolkitvcproj"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcproj (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcproj        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/aprtoolkit.vcproj        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -162,6 +162,10 @@
</span><span class="cx">                                 >
</span><span class="cx">                         </File>
</span><span class="cx">                         <File
</span><ins>+                                RelativePath=".\include\apt_nlsml_doc.h"
+                                >
+                        </File>
+                        <File
</ins><span class="cx">                                 RelativePath=".\include\apt_obj_list.h"
</span><span class="cx">                                 >
</span><span class="cx">                         </File>
</span><span class="lines">@@ -235,6 +239,10 @@
</span><span class="cx">                                 >
</span><span class="cx">                         </File>
</span><span class="cx">                         <File
</span><ins>+                                RelativePath=".\src\apt_nlsml_doc.c"
+                                >
+                        </File>
+                        <File
</ins><span class="cx">                                 RelativePath=".\src\apt_obj_list.c"
</span><span class="cx">                                 >
</span><span class="cx">                         </File>
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsaprtoolkitincludeapt_nlsml_doch"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h (0 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h         (rev 0)
+++ freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/include/apt_nlsml_doc.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright 2008 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 __APT_NLSML_DOC_H__
+#define __APT_NLSML_DOC_H__
+
+/**
+ * @file apt_nlsml_doc.h
+ * @brief Basic NLSML Routine
+ */
+
+#include "apr_xml.h"
+#include "apt_string.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);
+
+/** Get the first <interpretation> element */
+APT_DECLARE(apr_xml_elem*) nlsml_first_interpret_get(const apr_xml_doc *doc);
+
+/** Get the next <interpretation> element */
+APT_DECLARE(apr_xml_elem*) nlsml_next_interpret_get(const apr_xml_elem *interpret);
+
+/** 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);
+
+/** Get specified atrribute of <input> */
+APT_DECLARE(const char *) nlsml_input_attrib_get(const apr_xml_elem *input, const char *attrib, apt_bool_t recursive);
+
+
+APT_END_EXTERN_C
+
+#endif /*__APT_NLSML_DOC_H__*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsaprtoolkitsrcapt_nlsml_docc"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c (0 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c         (rev 0)
+++ freeswitch/trunk/libs/unimrcp/libs/apr-toolkit/src/apt_nlsml_doc.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+/*
+ * Copyright 2008 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.
+ */
+
+#include "apt_nlsml_doc.h"
+
+/** Load NLSML document */
+APT_DECLARE(apr_xml_doc*) nlsml_doc_load(const apt_str_t *data, apr_pool_t *pool)
+{
+        apr_xml_parser *parser;
+        apr_xml_doc *doc = NULL;
+        const apr_xml_elem *root;
+
+        /* create XML parser */
+        parser = apr_xml_parser_create(pool);
+        if(apr_xml_parser_feed(parser,data->buf,data->length) != APR_SUCCESS) {
+                return NULL;
+        }
+
+        /* done with XML tree creation */
+        if(apr_xml_parser_done(parser,&doc) != APR_SUCCESS) {
+                return NULL;
+        }
+
+        if(!doc || !doc->root) {
+                return NULL;
+        }
+        root = doc->root;
+
+        /* NLSML validity check: root element must be <result> */
+        if(strcmp(root->name,"result") != 0) {
+                return NULL;
+        }
+
+        return doc;
+}
+
+/** Get the first <interpretation> element */
+APT_DECLARE(apr_xml_elem*) nlsml_first_interpret_get(const apr_xml_doc *doc)
+{
+        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;
+                }
+        }
+
+        return NULL;
+}
+
+/** Get the next <interpretation> element */
+APT_DECLARE(apr_xml_elem*) nlsml_next_interpret_get(const apr_xml_elem *elem)
+{
+        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;
+                }
+        }
+
+        return NULL;
+}
+
+/** 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)
+{
+        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;
+                }
+                else if(strcmp(child_elem->name,"instance") == 0) {
+                        *instance = child_elem;
+                }
+        }
+        return TRUE;
+}
+
+/** Get specified atrribute of <input> */
+APT_DECLARE(const char *) nlsml_input_attrib_get(const apr_xml_elem *input, const char *attrib, apt_bool_t recursive)
+{
+        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;
+                }
+        }
+
+        if(recursive && input->parent) {
+                return nlsml_input_attrib_get(input->parent,attrib,recursive);
+        }
+
+        return NULL;
+}
</ins></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpcontrolincludemrcp_resourceh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_resource.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -40,9 +40,9 @@
</span><span class="cx">         apt_bool_t (*resourcify_message_by_name)(mrcp_resource_t *resource, mrcp_message_t *message);
</span><span class="cx">
</span><span class="cx">         /** Create client side state machine */
</span><del>-        mrcp_state_machine_t* (*create_client_state_machine)(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool);
</del><ins>+        mrcp_state_machine_t* (*create_client_state_machine)(void *obj, mrcp_version_e version, apr_pool_t *pool);
</ins><span class="cx">         /** Create server side state machine */
</span><del>-        mrcp_state_machine_t* (*create_server_state_machine)(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool);
</del><ins>+        mrcp_state_machine_t* (*create_server_state_machine)(void *obj, mrcp_version_e version, apr_pool_t *pool);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /** Initialize MRCP resource */
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpcontrolincludemrcp_state_machineh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_state_machine.h (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_state_machine.h        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/control/include/mrcp_state_machine.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -29,34 +29,56 @@
</span><span class="cx"> /** MRCP state machine declaration */
</span><span class="cx"> typedef struct mrcp_state_machine_t mrcp_state_machine_t;
</span><span class="cx">
</span><del>-/** MRCP message dispatcher */
-typedef apt_bool_t (*mrcp_message_dispatcher_f)(mrcp_state_machine_t *state_machine, mrcp_message_t *message);
</del><span class="cx">
</span><del>-
</del><span class="cx"> /** MRCP state machine */
</span><span class="cx"> struct mrcp_state_machine_t {
</span><span class="cx">         /** External object associated with state machine */
</span><span class="cx">         void *obj;
</span><del>-        /** Message dispatcher */
-        mrcp_message_dispatcher_f dispatcher;
</del><ins>+        /** State either active or deactivating */
+        apt_bool_t active;
</ins><span class="cx">
</span><span class="cx">         /** Virtual update */
</span><span class="cx">         apt_bool_t (*update)(mrcp_state_machine_t *state_machine, mrcp_message_t *message);
</span><ins>+        /** Deactivate */
+        apt_bool_t (*deactivate)(mrcp_state_machine_t *state_machine);
+
+
+        /** Message dispatcher */
+        apt_bool_t (*on_dispatch)(mrcp_state_machine_t *state_machine, mrcp_message_t *message);
+        /** Deactivated */
+        apt_bool_t (*on_deactivate)(mrcp_state_machine_t *state_machine);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /** Initialize MRCP state machine */
</span><del>-static APR_INLINE void mrcp_state_machine_init(mrcp_state_machine_t *state_machine, void *obj, mrcp_message_dispatcher_f dispatcher)
</del><ins>+static APR_INLINE void mrcp_state_machine_init(mrcp_state_machine_t *state_machine, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         state_machine->obj = obj;
</span><del>-        state_machine->dispatcher = dispatcher;
</del><ins>+        state_machine->active = TRUE;
+        state_machine->on_dispatch = NULL;
+        state_machine->on_deactivate = NULL;
+        state_machine->update = NULL;
+        state_machine->deactivate = NULL;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Update MRCP state machine */
</span><span class="cx"> static APR_INLINE apt_bool_t mrcp_state_machine_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><del>-        return state_machine->update(state_machine,message);
</del><ins>+        if(state_machine->update) {
+                return state_machine->update(state_machine,message);
+        }
+        return FALSE;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+/** Deactivate MRCP state machine */
+static APR_INLINE apt_bool_t mrcp_state_machine_deactivate(mrcp_state_machine_t *state_machine)
+{
+        if(state_machine->deactivate) {
+                state_machine->active = FALSE;
+                return state_machine->deactivate(state_machine);
+        }
+        return FALSE;
+}
+
</ins><span class="cx"> APT_END_EXTERN_C
</span><span class="cx">
</span><span class="cx"> #endif /*__MRCP_STATE_MACHINE_H__*/
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcesincludemrcp_recog_state_machineh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_state_machine.h (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_state_machine.h        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_recog_state_machine.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -27,10 +27,10 @@
</span><span class="cx"> APT_BEGIN_EXTERN_C
</span><span class="cx">
</span><span class="cx"> /** Create MRCP recognizer server state machine */
</span><del>-mrcp_state_machine_t* mrcp_recog_server_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool);
</del><ins>+mrcp_state_machine_t* mrcp_recog_server_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /** Create MRCP recognizer client state machine */
</span><del>-mrcp_state_machine_t* mrcp_recog_client_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool);
</del><ins>+mrcp_state_machine_t* mrcp_recog_client_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> APT_END_EXTERN_C
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcesincludemrcp_synth_state_machineh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_state_machine.h (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_state_machine.h        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/include/mrcp_synth_state_machine.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -27,10 +27,10 @@
</span><span class="cx"> APT_BEGIN_EXTERN_C
</span><span class="cx">
</span><span class="cx"> /** Create MRCP synthesizer server state machine */
</span><del>-mrcp_state_machine_t* mrcp_synth_server_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool);
</del><ins>+mrcp_state_machine_t* mrcp_synth_server_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /** Create MRCP synthesizer client state machine */
</span><del>-mrcp_state_machine_t* mrcp_synth_client_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool);
</del><ins>+mrcp_state_machine_t* mrcp_synth_client_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> APT_END_EXTERN_C
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_recog_client_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_client_state_machine.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_client_state_machine.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_client_state_machine.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -23,14 +23,14 @@
</span><span class="cx"> static apt_bool_t recog_state_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         /* no actual state machine processing yet, dispatch whatever received */
</span><del>-        return state_machine->dispatcher(state_machine,message);
</del><ins>+        return state_machine->on_dispatch(state_machine,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Create MRCP recognizer client state machine */
</span><del>-mrcp_state_machine_t* mrcp_recog_client_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool)
</del><ins>+mrcp_state_machine_t* mrcp_recog_client_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         mrcp_state_machine_t *state_machine = apr_palloc(pool,sizeof(mrcp_state_machine_t));
</span><del>-        mrcp_state_machine_init(state_machine,obj,dispatcher);
</del><ins>+        mrcp_state_machine_init(state_machine,obj);
</ins><span class="cx">         state_machine->update = recog_state_update;
</span><span class="cx">         return state_machine;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_recog_headerc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_header.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -14,6 +14,7 @@
</span><span class="cx"> * limitations under the License.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+#include <stdio.h>
</ins><span class="cx"> #include "mrcp_recog_header.h"
</span><span class="cx">
</span><span class="cx"> /** String table of MRCPv1 recognizer headers (mrcp_recog_header_id) */
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_recog_server_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_server_state_machine.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_server_state_machine.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_recog_server_state_machine.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -61,18 +61,26 @@
</span><span class="cx"> static APR_INLINE apt_bool_t recog_request_dispatch(mrcp_recog_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         state_machine->active_request = message;
</span><del>-        return state_machine->base.dispatcher(&state_machine->base,message);
</del><ins>+        return state_machine->base.on_dispatch(&state_machine->base,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static APR_INLINE apt_bool_t recog_response_dispatch(mrcp_recog_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         state_machine->active_request = NULL;
</span><del>-        return state_machine->base.dispatcher(&state_machine->base,message);
</del><ins>+        if(state_machine->base.active == FALSE) {
+                /* this is the response to deactivation (STOP) request */
+                return state_machine->base.on_deactivate(&state_machine->base);
+        }
+        return state_machine->base.on_dispatch(&state_machine->base,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static APR_INLINE apt_bool_t recog_event_dispatch(mrcp_recog_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><del>-        return state_machine->base.dispatcher(&state_machine->base,message);
</del><ins>+        if(state_machine->base.active == FALSE) {
+                /* do nothing, state machine has already been deactivated */
+                return FALSE;
+        }
+        return state_machine->base.on_dispatch(&state_machine->base,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static APR_INLINE void recog_state_change(mrcp_recog_state_machine_t *state_machine, mrcp_recog_state_e state)
</span><span class="lines">@@ -286,10 +294,10 @@
</span><span class="cx">         mrcp_generic_header_property_add(message,GENERIC_HEADER_ACTIVE_REQUEST_ID_LIST);
</span><span class="cx">         recog_pending_requests_remove(state_machine,state_machine->active_request,message);
</span><span class="cx">         recog_state_change(state_machine,RECOGNIZER_STATE_IDLE);
</span><ins>+        pending_request = apt_list_pop_front(state_machine->queue);
</ins><span class="cx">         recog_response_dispatch(state_machine,message);
</span><span class="cx">
</span><span class="cx">         /* process pending RECOGNIZE requests / if any */
</span><del>-        pending_request = apt_list_pop_front(state_machine->queue);
</del><span class="cx">         if(pending_request) {
</span><span class="cx">                 apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Process Pending RECOGNIZE Request [%d]",pending_request->start_line.request_id);
</span><span class="cx">                 state_machine->is_pending = TRUE;
</span><span class="lines">@@ -432,19 +440,19 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Update state according to request received from MRCP client or response/event received from recognition engine */
</span><del>-static apt_bool_t recog_state_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
</del><ins>+static apt_bool_t recog_state_update(mrcp_state_machine_t *base, mrcp_message_t *message)
</ins><span class="cx"> {
</span><del>-        mrcp_recog_state_machine_t *recog_state_machine = (mrcp_recog_state_machine_t*)state_machine;
</del><ins>+        mrcp_recog_state_machine_t *state_machine = (mrcp_recog_state_machine_t*)base;
</ins><span class="cx">         apt_bool_t status = TRUE;
</span><span class="cx">         switch(message->start_line.message_type) {
</span><span class="cx">                 case MRCP_MESSAGE_TYPE_REQUEST:
</span><del>-                        status = recog_request_state_update(recog_state_machine,message);
</del><ins>+                        status = recog_request_state_update(state_machine,message);
</ins><span class="cx">                         break;
</span><span class="cx">                 case MRCP_MESSAGE_TYPE_RESPONSE:
</span><del>-                        status = recog_response_state_update(recog_state_machine,message);
</del><ins>+                        status = recog_response_state_update(state_machine,message);
</ins><span class="cx">                         break;
</span><span class="cx">                 case MRCP_MESSAGE_TYPE_EVENT:
</span><del>-                        status = recog_event_state_update(recog_state_machine,message);
</del><ins>+                        status = recog_event_state_update(state_machine,message);
</ins><span class="cx">                         break;
</span><span class="cx">                 default:
</span><span class="cx">                         status = FALSE;
</span><span class="lines">@@ -453,13 +461,42 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/** Deactivate state machine */
+static apt_bool_t recog_state_deactivate(mrcp_state_machine_t *base)
+{
+        mrcp_recog_state_machine_t *state_machine = (mrcp_recog_state_machine_t*)base;
+        mrcp_message_t *message;
+        mrcp_message_t *source;
+        if(state_machine->state != RECOGNIZER_STATE_RECOGNIZING) {
+                /* no in-progress RECOGNIZE request to deactivate */
+                return FALSE;
+        }
+        source = state_machine->recog;
+        if(!source) {
+                return FALSE;
+        }
+
+        /* create internal STOP request */
+        message = mrcp_request_create(
+                                                source->channel_id.resource_id,
+                                                RECOGNIZER_STOP,
+                                                source->pool);
+        message->channel_id = source->channel_id;
+        message->start_line.request_id = source->start_line.request_id + 1;
+        apt_string_set(&message->start_line.method_name,"DEACTIVATE"); /* informative only */
+        message->header = source->header;
+        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create and Process STOP Request [%d]",message->start_line.request_id);
+        return recog_request_dispatch(state_machine,message);
+}
+
</ins><span class="cx"> /** Create MRCP recognizer server state machine */
</span><del>-mrcp_state_machine_t* mrcp_recog_server_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool)
</del><ins>+mrcp_state_machine_t* mrcp_recog_server_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         mrcp_message_header_t *properties;
</span><span class="cx">         mrcp_recog_state_machine_t *state_machine = apr_palloc(pool,sizeof(mrcp_recog_state_machine_t));
</span><del>-        mrcp_state_machine_init(&state_machine->base,obj,dispatcher);
</del><ins>+        mrcp_state_machine_init(&state_machine->base,obj);
</ins><span class="cx">         state_machine->base.update = recog_state_update;
</span><ins>+        state_machine->base.deactivate = recog_state_deactivate;
</ins><span class="cx">         state_machine->state = RECOGNIZER_STATE_IDLE;
</span><span class="cx">         state_machine->is_pending = FALSE;
</span><span class="cx">         state_machine->active_request = NULL;
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_synth_client_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_client_state_machine.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_client_state_machine.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_client_state_machine.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -23,14 +23,14 @@
</span><span class="cx"> static apt_bool_t synth_state_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         /* no actual state machine processing yet, dispatch whatever received */
</span><del>-        return state_machine->dispatcher(state_machine,message);
</del><ins>+        return state_machine->on_dispatch(state_machine,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Create MRCP synthesizer client state machine */
</span><del>-mrcp_state_machine_t* mrcp_synth_client_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool)
</del><ins>+mrcp_state_machine_t* mrcp_synth_client_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         mrcp_state_machine_t *state_machine = apr_palloc(pool,sizeof(mrcp_state_machine_t));
</span><del>-        mrcp_state_machine_init(state_machine,obj,dispatcher);
</del><ins>+        mrcp_state_machine_init(state_machine,obj);
</ins><span class="cx">         state_machine->update = synth_state_update;
</span><span class="cx">         return state_machine;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_synth_headerc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_header.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -14,6 +14,7 @@
</span><span class="cx"> * limitations under the License.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+#include <stdio.h>
</ins><span class="cx"> #include "mrcp_synth_header.h"
</span><span class="cx">
</span><span class="cx"> /** String table of MRCP synthesizer headers (mrcp_synthesizer_header_id) */
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpresourcessrcmrcp_synth_server_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_server_state_machine.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_server_state_machine.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp/resources/src/mrcp_synth_server_state_machine.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -61,18 +61,26 @@
</span><span class="cx"> static APR_INLINE apt_bool_t synth_request_dispatch(mrcp_synth_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         state_machine->active_request = message;
</span><del>-        return state_machine->base.dispatcher(&state_machine->base,message);
</del><ins>+        return state_machine->base.on_dispatch(&state_machine->base,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static APR_INLINE apt_bool_t synth_response_dispatch(mrcp_synth_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         state_machine->active_request = NULL;
</span><del>-        return state_machine->base.dispatcher(&state_machine->base,message);
</del><ins>+        if(state_machine->base.active == FALSE) {
+                /* this is the response to deactivation (STOP) request */
+                return state_machine->base.on_deactivate(&state_machine->base);
+        }
+        return state_machine->base.on_dispatch(&state_machine->base,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static APR_INLINE apt_bool_t synth_event_dispatch(mrcp_synth_state_machine_t *state_machine, mrcp_message_t *message)
</span><span class="cx"> {
</span><del>-        return state_machine->base.dispatcher(&state_machine->base,message);
</del><ins>+        if(state_machine->base.active == FALSE) {
+                /* do nothing, state machine has already been deactivated */
+                return FALSE;
+        }
+        return state_machine->base.on_dispatch(&state_machine->base,message);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static APR_INLINE void synth_state_change(mrcp_synth_state_machine_t *state_machine, mrcp_synth_state_e state)
</span><span class="lines">@@ -220,10 +228,10 @@
</span><span class="cx">         mrcp_generic_header_property_add(message,GENERIC_HEADER_ACTIVE_REQUEST_ID_LIST);
</span><span class="cx">         synth_pending_requests_remove(state_machine,state_machine->active_request,message);
</span><span class="cx">         synth_state_change(state_machine,SYNTHESIZER_STATE_IDLE);
</span><ins>+        pending_request = apt_list_pop_front(state_machine->queue);
</ins><span class="cx">         synth_response_dispatch(state_machine,message);
</span><span class="cx">
</span><span class="cx">         /* process pending SPEAK requests / if any */
</span><del>-        pending_request = apt_list_pop_front(state_machine->queue);
</del><span class="cx">         if(pending_request) {
</span><span class="cx">                 apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Process Pending SPEAK Request [%d]",pending_request->start_line.request_id);
</span><span class="cx">                 state_machine->is_pending = TRUE;
</span><span class="lines">@@ -522,9 +530,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Update state according to request received from MRCP client or response/event received from synthesizer engine */
</span><del>-static apt_bool_t synth_state_update(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
</del><ins>+static apt_bool_t synth_state_update(mrcp_state_machine_t *base, mrcp_message_t *message)
</ins><span class="cx"> {
</span><del>-        mrcp_synth_state_machine_t *synth_state_machine = (mrcp_synth_state_machine_t*)state_machine;
</del><ins>+        mrcp_synth_state_machine_t *synth_state_machine = (mrcp_synth_state_machine_t*)base;
</ins><span class="cx">         apt_bool_t status = TRUE;
</span><span class="cx">         switch(message->start_line.message_type) {
</span><span class="cx">                 case MRCP_MESSAGE_TYPE_REQUEST:
</span><span class="lines">@@ -543,13 +551,39 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/** Deactivate state machine */
+static apt_bool_t synth_state_deactivate(mrcp_state_machine_t *base)
+{
+        mrcp_synth_state_machine_t *state_machine = (mrcp_synth_state_machine_t*)base;
+        mrcp_message_t *message;
+        mrcp_message_t *source;
+        if(!state_machine->speaker) {
+                /* no in-progress SPEAK request to deactivate */
+                return FALSE;
+        }
+        source = state_machine->speaker;
+
+        /* create internal STOP request */
+        message = mrcp_request_create(
+                                                source->channel_id.resource_id,
+                                                SYNTHESIZER_STOP,
+                                                source->pool);
+        message->channel_id = source->channel_id;
+        message->start_line.request_id = source->start_line.request_id + 1;
+        apt_string_set(&message->start_line.method_name,"DEACTIVATE"); /* informative only */
+        message->header = source->header;
+        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Create and Process STOP Request [%d]",message->start_line.request_id);
+        return synth_request_dispatch(state_machine,message);
+}
+
</ins><span class="cx"> /** Create MRCP synthesizer server state machine */
</span><del>-mrcp_state_machine_t* mrcp_synth_server_state_machine_create(void *obj, mrcp_message_dispatcher_f dispatcher, mrcp_version_e version, apr_pool_t *pool)
</del><ins>+mrcp_state_machine_t* mrcp_synth_server_state_machine_create(void *obj, mrcp_version_e version, apr_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         mrcp_message_header_t *properties;
</span><span class="cx">         mrcp_synth_state_machine_t *state_machine = apr_palloc(pool,sizeof(mrcp_synth_state_machine_t));
</span><del>-        mrcp_state_machine_init(&state_machine->base,obj,dispatcher);
</del><ins>+        mrcp_state_machine_init(&state_machine->base,obj);
</ins><span class="cx">         state_machine->base.update = synth_state_update;
</span><ins>+        state_machine->base.deactivate = synth_state_deactivate;
</ins><span class="cx">         state_machine->state = SYNTHESIZER_STATE_IDLE;
</span><span class="cx">         state_machine->is_pending = FALSE;
</span><span class="cx">         state_machine->active_request = NULL;
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpserverincludemrcp_server_sessionh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp-server/include/mrcp_server_session.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -93,6 +93,8 @@
</span><span class="cx">         apr_size_t answer_flag_count;
</span><span class="cx">         /** Number of in-progress terminate requests (flags) */
</span><span class="cx">         apr_size_t terminate_flag_count;
</span><ins>+        /** Number of in-progress deactivare requests (flags) */
+        apr_size_t deactivate_flag_count;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /** MRCP profile */
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpserversrcmrcp_serverc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -595,7 +595,7 @@
</span><span class="cx"> void mrcp_server_session_add(mrcp_server_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         if(session->base.id.buf) {
</span><del>-                apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Add Session "APT_SID_FMT,session->base.id.buf);
</del><ins>+                apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Add Session "APT_SID_FMT,MRCP_SESSION_SID(&session->base));
</ins><span class="cx">                 apr_hash_set(session->server->session_table,session->base.id.buf,session->base.id.length,session);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -603,7 +603,7 @@
</span><span class="cx"> void mrcp_server_session_remove(mrcp_server_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         if(session->base.id.buf) {
</span><del>-                apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Remove Session "APT_SID_FMT,session->base.id.buf);
</del><ins>+                apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Remove Session "APT_SID_FMT,MRCP_SESSION_SID(&session->base));
</ins><span class="cx">                 apr_hash_set(session->server->session_table,session->base.id.buf,session->base.id.length,NULL);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -820,7 +820,7 @@
</span><span class="cx">                         return profile;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Find Profile by Agent "APT_SID_FMT,session->base.id.buf);
</del><ins>+        apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Find Profile by Agent "APT_SID_FMT,MRCP_SESSION_SID(&session->base));
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcplibsmrcpserversrcmrcp_server_sessionc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/libs/mrcp-server/src/mrcp_server_session.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -93,7 +93,10 @@
</span><span class="cx">                                                 mpf_termination_t *termination,
</span><span class="cx">                                                 void *descriptor);
</span><span class="cx">
</span><ins>+static apt_bool_t state_machine_on_message_dispatch(mrcp_state_machine_t *state_machine, mrcp_message_t *message);
+static apt_bool_t state_machine_on_deactivate(mrcp_state_machine_t *state_machine);
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> mrcp_server_session_t* mrcp_server_session_create()
</span><span class="cx"> {
</span><span class="cx">         mrcp_server_session_t *session = (mrcp_server_session_t*) mrcp_session_create(sizeof(mrcp_server_session_t)-sizeof(mrcp_session_t));
</span><span class="lines">@@ -106,6 +109,7 @@
</span><span class="cx">         session->answer = NULL;
</span><span class="cx">         session->answer_flag_count = 0;
</span><span class="cx">         session->terminate_flag_count = 0;
</span><ins>+        session->deactivate_flag_count = 0;
</ins><span class="cx">         return session;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -123,47 +127,6 @@
</span><span class="cx">         return resource_engine->method_vtable->create_channel(resource_engine,session->base.pool);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static apt_bool_t mrcp_server_message_dispatch(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
-{
-        mrcp_channel_t *channel = state_machine->obj;
-
-        if(message->start_line.message_type == MRCP_MESSAGE_TYPE_REQUEST) {
-                /* send request message to resource engine for actual processing */
-                if(channel->engine_channel) {
-                        mrcp_engine_channel_request_process(channel->engine_channel,message);
-                }
-        }
-        else if(message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
-                mrcp_server_session_t *session = (mrcp_server_session_t*)channel->session;
-                /* send response message to client */
-                if(channel->control_channel) {
-                        /* MRCPv2 */
-                        mrcp_server_control_message_send(channel->control_channel,message);
-                }
-                else {
-                        /* MRCPv1 */
-                        mrcp_session_control_response(channel->session,message);
-                }
-
-                session->active_request = apt_list_pop_front(session->request_queue);
-                if(session->active_request) {
-                        mrcp_server_signaling_message_dispatch(session,session->active_request);
-                }
-        }
-        else {
-                /* send event message to client */
-                if(channel->control_channel) {
-                        /* MRCPv2 */
-                        mrcp_server_control_message_send(channel->control_channel,message);
-                }
-                else {
-                        /* MRCPv1 */
-                        mrcp_session_control_response(channel->session,message);
-                }
-        }
-        return TRUE;
-}
-
</del><span class="cx"> static mrcp_channel_t* mrcp_server_channel_create(mrcp_server_session_t *session, const apt_str_t *resource_name, apr_size_t id)
</span><span class="cx"> {
</span><span class="cx">         mrcp_channel_t *channel;
</span><span class="lines">@@ -200,9 +163,12 @@
</span><span class="cx">                         }
</span><span class="cx">                         channel->state_machine = resource->create_server_state_machine(
</span><span class="cx">                                                                 channel,
</span><del>-                                                                mrcp_server_message_dispatch,
</del><span class="cx">                                                                 session->base.signaling_agent->mrcp_version,
</span><span class="cx">                                                                 pool);
</span><ins>+                        if(channel->state_machine) {
+                                channel->state_machine->on_dispatch = state_machine_on_message_dispatch;
+                                channel->state_machine->on_deactivate = state_machine_on_deactivate;
+                        }
</ins><span class="cx">
</span><span class="cx">                         engine_channel = mrcp_server_engine_channel_create(session,resource_name);
</span><span class="cx">                         if(engine_channel) {
</span><span class="lines">@@ -413,7 +379,7 @@
</span><span class="cx">                 session->context = mpf_context_create(session,5,session->base.pool);
</span><span class="cx">         }
</span><span class="cx">         apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive Offer "APT_SID_FMT" [c:%d a:%d v:%d]",
</span><del>-                session->base.id.buf,
</del><ins>+                MRCP_SESSION_SID(&session->base),
</ins><span class="cx">                 descriptor->control_media_arr->nelts,
</span><span class="cx">                 descriptor->audio_media_arr->nelts,
</span><span class="cx">                 descriptor->video_media_arr->nelts);
</span><span class="lines">@@ -447,7 +413,7 @@
</span><span class="cx">         mrcp_channel_t *channel;
</span><span class="cx">         mrcp_termination_slot_t *slot;
</span><span class="cx">         int i;
</span><del>-        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive Terminate Request "APT_SID_FMT,session->base.id.buf);
</del><ins>+        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive Terminate Request "APT_SID_FMT,MRCP_SESSION_SID(&session->base));
</ins><span class="cx">         for(i=0; i<session->channels->nelts; i++) {
</span><span class="cx">                 channel = ((mrcp_channel_t**)session->channels->elts)[i];
</span><span class="cx">                 if(!channel) continue;
</span><span class="lines">@@ -499,6 +465,27 @@
</span><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static apt_bool_t mrcp_server_session_deactivate(mrcp_server_session_t *session)
+{
+        mrcp_channel_t *channel;
+        int i;
+        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Deactivate Session "APT_SID_FMT,MRCP_SESSION_SID(&session->base));
+        for(i=0; i<session->channels->nelts; i++) {
+                channel = ((mrcp_channel_t**)session->channels->elts)[i];
+                if(!channel || !channel->state_machine) continue;
+
+                if(mrcp_state_machine_deactivate(channel->state_machine) == TRUE) {
+                        session->deactivate_flag_count++;
+                }
+        }
+        
+        if(!session->deactivate_flag_count) {
+                mrcp_server_session_terminate_process(session);
+        }
+
+        return TRUE;
+}
+
</ins><span class="cx"> static apt_bool_t mrcp_server_on_message_receive(mrcp_server_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         if(!channel) {
</span><span class="lines">@@ -528,7 +515,7 @@
</span><span class="cx">                         mrcp_server_on_message_receive(signaling_message->session,signaling_message->channel,signaling_message->message);
</span><span class="cx">                         break;
</span><span class="cx">                 case SIGNALING_MESSAGE_TERMINATE:
</span><del>-                        mrcp_server_session_terminate_process(signaling_message->session);
</del><ins>+                        mrcp_server_session_deactivate(signaling_message->session);
</ins><span class="cx">                         break;
</span><span class="cx">                 default:
</span><span class="cx">                         break;
</span><span class="lines">@@ -749,7 +736,7 @@
</span><span class="cx">         apt_bool_t status;
</span><span class="cx">         mrcp_session_descriptor_t *descriptor = session->answer;
</span><span class="cx">         apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Send Answer "APT_SID_FMT" [c:%d a:%d v:%d] Status %s",
</span><del>-                session->base.id.buf,
</del><ins>+                MRCP_SESSION_SID(&session->base),
</ins><span class="cx">                 descriptor->control_media_arr->nelts,
</span><span class="cx">                 descriptor->audio_media_arr->nelts,
</span><span class="cx">                 descriptor->video_media_arr->nelts,
</span><span class="lines">@@ -782,7 +769,7 @@
</span><span class="cx">                         channel->engine_channel = NULL;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Send Terminate Response "APT_SID_FMT,session->base.id.buf);
</del><ins>+        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Send Terminate Response "APT_SID_FMT,MRCP_SESSION_SID(&session->base));
</ins><span class="cx">         mrcp_session_terminate_response(&session->base);
</span><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="lines">@@ -912,6 +899,60 @@
</span><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static apt_bool_t state_machine_on_message_dispatch(mrcp_state_machine_t *state_machine, mrcp_message_t *message)
+{
+        mrcp_channel_t *channel = state_machine->obj;
+
+        if(message->start_line.message_type == MRCP_MESSAGE_TYPE_REQUEST) {
+                /* send request message to resource engine for actual processing */
+                if(channel->engine_channel) {
+                        mrcp_engine_channel_request_process(channel->engine_channel,message);
+                }
+        }
+        else if(message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
+                mrcp_server_session_t *session = (mrcp_server_session_t*)channel->session;
+                /* send response message to client */
+                if(channel->control_channel) {
+                        /* MRCPv2 */
+                        mrcp_server_control_message_send(channel->control_channel,message);
+                }
+                else {
+                        /* MRCPv1 */
+                        mrcp_session_control_response(channel->session,message);
+                }
+
+                session->active_request = apt_list_pop_front(session->request_queue);
+                if(session->active_request) {
+                        mrcp_server_signaling_message_dispatch(session,session->active_request);
+                }
+        }
+        else {
+                /* send event message to client */
+                if(channel->control_channel) {
+                        /* MRCPv2 */
+                        mrcp_server_control_message_send(channel->control_channel,message);
+                }
+                else {
+                        /* MRCPv1 */
+                        mrcp_session_control_response(channel->session,message);
+                }
+        }
+        return TRUE;
+}
+
+static apt_bool_t state_machine_on_deactivate(mrcp_state_machine_t *state_machine)
+{
+        mrcp_channel_t *channel = state_machine->obj;
+        mrcp_server_session_t *session = (mrcp_server_session_t*)channel->session;
+        if(session->deactivate_flag_count) {
+                session->deactivate_flag_count --;
+                if(!session->deactivate_flag_count) {
+                        mrcp_server_session_terminate_process(session);
+                }
+        }
+        return TRUE;
+}
+
</ins><span class="cx"> static apt_bool_t mrcp_server_mpf_request_send(
</span><span class="cx">                                                 mrcp_server_session_t *session,
</span><span class="cx">                                                 mpf_command_type_e command_id,
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpmodulesmrcpsofiasipsrcmrcp_sdpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/modules/mrcp-sofiasip/src/mrcp_sdp.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -14,7 +14,7 @@
</span><span class="cx"> * limitations under the License.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-
</del><ins>+#include <stdlib.h>
</ins><span class="cx"> #include <apr_general.h>
</span><span class="cx"> #include <sofia-sip/sdp.h>
</span><span class="cx"> #include "mrcp_sdp.h"
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpmodulesmrcpunirtspsrcmrcp_unirtsp_sdpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/modules/mrcp-unirtsp/src/mrcp_unirtsp_sdp.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -14,6 +14,7 @@
</span><span class="cx"> * limitations under the License.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+#include <stdlib.h>
</ins><span class="cx"> #include <apr_general.h>
</span><span class="cx"> #include <sofia-sip/sdp.h>
</span><span class="cx"> #include "rtsp_message.h"
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpplatformslibunimrcpclientsrcunimrcp_clientc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-client/src/unimrcp_client.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -14,6 +14,7 @@
</span><span class="cx"> * limitations under the License.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+#include <stdlib.h>
</ins><span class="cx"> #include <apr_xml.h>
</span><span class="cx"> #include "unimrcp_client.h"
</span><span class="cx"> #include "uni_version.h"
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpplatformslibunimrcpserversrcunimrcp_serverc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/platforms/libunimrcp-server/src/unimrcp_server.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -14,6 +14,7 @@
</span><span class="cx"> * limitations under the License.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+#include <stdlib.h>
</ins><span class="cx"> #include <apr_xml.h>
</span><span class="cx"> #include "unimrcp_server.h"
</span><span class="cx"> #include "uni_version.h"
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpplatformsunimrcpclientincludedemo_utilh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/include/demo_util.h        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -34,6 +34,8 @@
</span><span class="cx"> /** Create demo MRCP message (RECOGNIZE request) */
</span><span class="cx"> mrcp_message_t* demo_recognize_message_create(mrcp_session_t *session, mrcp_channel_t *channel, const apt_dir_layout_t *dir_layout);
</span><span class="cx">
</span><ins>+/** Parse NLSML result */
+apt_bool_t demo_nlsml_result_parse(mrcp_message_t *message);
</ins><span class="cx">
</span><span class="cx"> /** Create demo RTP termination descriptor */
</span><span class="cx"> mpf_rtp_termination_descriptor_t* demo_rtp_descriptor_create(apr_pool_t *pool);
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpplatformsunimrcpclientsrcdemo_recog_applicationc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_recog_application.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -291,6 +291,7 @@
</span><span class="cx">         }
</span><span class="cx">         else if(message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
</span><span class="cx">                 if(message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
</span><ins>+                        demo_nlsml_result_parse(message);
</ins><span class="cx">                         if(recog_channel) {
</span><span class="cx">                                 recog_channel->streaming = FALSE;
</span><span class="cx">                         }
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcpplatformsunimrcpclientsrcdemo_utilc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/platforms/unimrcp-client/src/demo_util.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -25,6 +25,10 @@
</span><span class="cx"> /* recognizer includes */
</span><span class="cx"> #include "mrcp_recog_header.h"
</span><span class="cx"> #include "mrcp_recog_resource.h"
</span><ins>+/* NLSML doc include */
+#include "apt_nlsml_doc.h"
+/* logger include */
+#include "apt_log.h"
</ins><span class="cx">
</span><span class="cx"> static void demo_message_body_set(mrcp_message_t *mrcp_message, const apt_dir_layout_t *dir_layout, const char *file_name)
</span><span class="cx"> {
</span><span class="lines">@@ -127,6 +131,8 @@
</span><span class="cx">                         mrcp_resource_header_property_add(mrcp_message,RECOGNIZER_HEADER_RECOGNITION_TIMEOUT);
</span><span class="cx">                         recog_header->start_input_timers = TRUE;
</span><span class="cx">                         mrcp_resource_header_property_add(mrcp_message,RECOGNIZER_HEADER_START_INPUT_TIMERS);
</span><ins>+                        recog_header->confidence_threshold = 0.87f;
+                        mrcp_resource_header_property_add(mrcp_message,RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD);
</ins><span class="cx">                 }
</span><span class="cx">                 /* set message body */
</span><span class="cx">                 apt_string_assign(&mrcp_message->body,text,mrcp_message->pool);
</span><span class="lines">@@ -134,6 +140,37 @@
</span><span class="cx">         return mrcp_message;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/** 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;
+}
</ins><span class="cx">
</span><span class="cx"> /** Create demo RTP termination descriptor */
</span><span class="cx"> mpf_rtp_termination_descriptor_t* demo_rtp_descriptor_create(apr_pool_t *pool)
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcppluginsmrcpflitesrcmrcp_flitec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/plugins/mrcp-flite/src/mrcp_flite.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -119,6 +119,8 @@
</span><span class="cx"> /* we have a special task for the actual synthesis -
</span><span class="cx"> the task is created when a mrcp speak message is received */
</span><span class="cx"> static apt_bool_t flite_speak(apt_task_t *task, apt_task_msg_t *msg);
</span><ins>+static apt_bool_t flite_on_start(apt_task_t *task);
+static apt_bool_t flite_on_terminate(apt_task_t *task);
</ins><span class="cx">
</span><span class="cx"> /** Declare this macro to use log routine of the server where the plugin is loaded from */
</span><span class="cx"> MRCP_PLUGIN_LOGGER_IMPLEMENT
</span><span class="lines">@@ -184,14 +186,16 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         task_vtable = apt_consumer_task_vtable_get(consumer_task);
</span><del>-        if(!task_vtable) {
-                apt_log(APT_LOG_MARK,APT_PRIO_ERROR, "flite_synth_channel_speak cannot use flite speak task vtable - channel:%d", synth_channel->iId);
-                return FALSE;
</del><ins>+        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;
</ins><span class="cx">         }
</span><del>-
-        task_vtable->process_msg = flite_speak;
</del><span class="cx">         synth_channel->msg_pool = msg_pool;
</span><span class="cx">         synth_channel->task = apt_consumer_task_base_get(consumer_task);
</span><ins>+        if(synth_channel->task) {
+                apt_task_name_set(synth_channel->task,"Flite Task");
+        }
</ins><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -199,19 +203,10 @@
</span><span class="cx"> static mrcp_engine_channel_t* flite_synth_engine_channel_create(mrcp_resource_engine_t *engine, apr_pool_t *pool)
</span><span class="cx"> {
</span><span class="cx">         /* create flite synth channel */
</span><ins>+        mpf_codec_descriptor_t *codec_descriptor = NULL;
</ins><span class="cx">         flite_synth_channel_t *synth_channel = (flite_synth_channel_t *) apr_palloc(pool,sizeof(flite_synth_channel_t));
</span><del>-        mpf_codec_descriptor_t *codec_descriptor = NULL;
</del><span class="cx">
</span><span class="cx">         apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_engine_channel_create");
</span><del>-#if 0
-        codec_descriptor = (mpf_codec_descriptor_t *) apr_palloc(pool,sizeof(mpf_codec_descriptor_t));
-        mpf_codec_descriptor_init(codec_descriptor);
-        codec_descriptor->channel_count = 1;
-        codec_descriptor->payload_type = 96;
-        apt_string_set(&codec_descriptor->name,"LPCM");
-        codec_descriptor->sampling_rate = 16000;
-#endif
-
</del><span class="cx">         synth_channel->flite_engine = (flite_synth_engine_t *) engine->obj;
</span><span class="cx">         synth_channel->speak_request = NULL; // no active speak request in progress
</span><span class="cx">         synth_channel->speak_response = NULL;
</span><span class="lines">@@ -228,6 +223,15 @@
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+#if 0
+        codec_descriptor = (mpf_codec_descriptor_t *) apr_palloc(pool,sizeof(mpf_codec_descriptor_t));
+        mpf_codec_descriptor_init(codec_descriptor);
+        codec_descriptor->channel_count = 1;
+        codec_descriptor->payload_type = 96;
+        apt_string_set(&codec_descriptor->name,"LPCM");
+        codec_descriptor->sampling_rate = 16000;
+#endif
+
</ins><span class="cx">         /* create engine channel base */
</span><span class="cx">         synth_channel->channel = mrcp_engine_source_channel_create(
</span><span class="cx">                         engine, /* resource engine */
</span><span class="lines">@@ -272,14 +276,15 @@
</span><span class="cx">
</span><span class="cx">         if(synth_channel->task) {
</span><span class="cx">                 if(apt_task_start(synth_channel->task) == TRUE) {
</span><del>-                        apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "Speak task started - channel %d", synth_channel->iId);
</del><ins>+                        /* async response will be sent */
+                        return TRUE;
</ins><span class="cx">                 }
</span><span class="cx">                 else {
</span><span class="cx">                         apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "Speak task start failed - channel %d", synth_channel->iId);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        return mrcp_engine_channel_open_respond(channel,TRUE);
</del><ins>+        return mrcp_engine_channel_open_respond(channel,FALSE);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Close engine channel (asynchronous response MUST be sent)*/
</span><span class="lines">@@ -289,15 +294,15 @@
</span><span class="cx">         apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "flite_synth_channel_close - channel %d", synth_channel->iId);
</span><span class="cx">
</span><span class="cx">         if(synth_channel->task) {
</span><del>-                if(apt_task_terminate(synth_channel->task,TRUE) == TRUE) {
-                        apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "Speak task terminated - channel %d", synth_channel->iId);
</del><ins>+                if(apt_task_terminate(synth_channel->task,FALSE) == TRUE) {
+                        /* async response will be sent */
+                        return TRUE;
</ins><span class="cx">                 }
</span><span class="cx">                 else {
</span><span class="cx">                         apt_log(APT_LOG_MARK, APT_PRIO_WARNING, "Speak task terminate failed - channel %d", synth_channel->iId);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        mrcp_engine_channel_close_respond(channel);
-        return TRUE;
</del><ins>+        return mrcp_engine_channel_close_respond(channel);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Process MRCP channel request (asynchronous response MUST be sent)*/
</span><span class="lines">@@ -428,7 +433,7 @@
</span><span class="cx">         apt_log(APT_LOG_MARK, APT_PRIO_DEBUG, "< flite_speak_msg_process speak - channel %d", synth_channel->iId);
</span><span class="cx">         
</span><span class="cx">         /* just sequential stuff */
</span><del>-        start = apr_time_now();        // in microsec
</del><ins>+        start = apr_time_now();        /* in microsec */
</ins><span class="cx">         if(!body->length) {
</span><span class="cx">                 synth_channel->speak_request = NULL;
</span><span class="cx">                 synth_response_construct(response,MRCP_STATUS_CODE_MISSING_PARAM,SYNTHESIZER_COMPLETION_CAUSE_ERROR);
</span><span class="lines">@@ -479,7 +484,7 @@
</span><span class="cx">                 delete_wave(wave);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        // this will notify the callback that feeds the client that synthesis is complete
</del><ins>+        /* this will notify the callback that feeds the client that synthesis is complete */
</ins><span class="cx">         mpf_buffer_event_write(synth_channel->audio_buffer, MEDIA_FRAME_TYPE_EVENT);
</span><span class="cx">         synth_channel->synthesizing = FALSE;
</span><span class="cx">
</span><span class="lines">@@ -487,6 +492,26 @@
</span><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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 apt_bool_t 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);
+        return mrcp_engine_channel_open_respond(synth_channel->channel,TRUE);
+}
+
+static apt_bool_t 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);
+        return mrcp_engine_channel_close_respond(synth_channel->channel);
+}
+
</ins><span class="cx"> /** Process STOP request */
</span><span class="cx"> static apt_bool_t flite_synth_channel_stop(mrcp_engine_channel_t *channel, mrcp_message_t *request, mrcp_message_t *response)
</span><span class="cx"> {
</span></span></pre></div>
<a id="freeswitchtrunklibsunimrcppluginsmrcppocketsphinxsrcmrcp_pocketsphinxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c (14259 => 14260)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c        2009-07-15 16:54:20 UTC (rev 14259)
+++ freeswitch/trunk/libs/unimrcp/plugins/mrcp-pocketsphinx/src/mrcp_pocketsphinx.c        2009-07-15 20:30:39 UTC (rev 14260)
</span><span class="lines">@@ -237,7 +237,10 @@
</span><span class="cx">                         recognizer, /* object to associate */
</span><span class="cx">                         NULL, /* codec descriptor might be NULL by default */
</span><span class="cx">                         pool); /* pool to allocate memory from */
</span><del>-        
</del><ins>+
+        apr_thread_mutex_create(&recognizer->mutex,APR_THREAD_MUTEX_DEFAULT,channel->pool);
+        apr_thread_cond_create(&recognizer->wait_object,channel->pool);
+
</ins><span class="cx">         recognizer->channel = channel;
</span><span class="cx">         return channel;
</span><span class="cx"> }
</span><span class="lines">@@ -245,6 +248,15 @@
</span><span class="cx"> /** Destroy pocketsphinx recognizer */
</span><span class="cx"> static apt_bool_t pocketsphinx_recognizer_destroy(mrcp_engine_channel_t *channel)
</span><span class="cx"> {
</span><ins>+        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;
+        }
</ins><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -256,17 +268,10 @@
</span><span class="cx">
</span><span class="cx">         apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Channel "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer));
</span><span class="cx">
</span><del>-        apr_thread_mutex_create(&recognizer->mutex,APR_THREAD_MUTEX_DEFAULT,channel->pool);
-        apr_thread_cond_create(&recognizer->wait_object,channel->pool);
-
</del><span class="cx">         /* Launch a thread to run recognition in */
</span><span class="cx">         rv = apr_thread_create(&recognizer->thread,NULL,pocketsphinx_recognizer_run,recognizer,channel->pool);
</span><span class="cx">         if(rv != APR_SUCCESS) {
</span><span class="cx">                 apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Failed to Launch Thread "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer));
</span><del>-                apr_thread_mutex_destroy(recognizer->mutex);
-                recognizer->mutex = NULL;
-                apr_thread_cond_destroy(recognizer->wait_object);
-                recognizer->wait_object = NULL;
</del><span class="cx">                 return mrcp_engine_channel_open_respond(channel,FALSE);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -278,25 +283,16 @@
</span><span class="cx"> {
</span><span class="cx">         pocketsphinx_recognizer_t *recognizer = channel->method_obj;
</span><span class="cx">         apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close Channel "APT_SIDRES_FMT,RECOGNIZER_SIDRES(recognizer));
</span><del>-        if(recognizer->thread) {
-                apr_status_t rv;
-                
-                /* Signal recognition thread to terminate */
-                apr_thread_mutex_lock(recognizer->mutex);
-                recognizer->close_requested = TRUE;
-                apr_thread_cond_signal(recognizer->wait_object);
-                apr_thread_mutex_unlock(recognizer->mutex);
-
-                apr_thread_join(&rv,recognizer->thread);
-                recognizer->thread = NULL;
-
-                apr_thread_mutex_destroy(recognizer->mutex);
-                recognizer->mutex = NULL;
-                apr_thread_cond_destroy(recognizer->wait_object);
-                recognizer->wait_object = NULL;
</del><ins>+        if(!recognizer->thread) {
+                return mrcp_engine_channel_close_respond(channel);
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        return mrcp_engine_channel_close_respond(channel);
</del><ins>+        /* Signal recognition thread to terminate */
+        apr_thread_mutex_lock(recognizer->mutex);
+        recognizer->close_requested = TRUE;
+        apr_thread_cond_signal(recognizer->wait_object);
+        apr_thread_mutex_unlock(recognizer->mutex);
+        return TRUE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Process MRCP request (asynchronous response MUST be sent)*/
</span><span class="lines">@@ -533,12 +529,10 @@
</span><span class="cx">                 return FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        response_recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_SUCCESS;
-        mrcp_resource_header_property_add(response,RECOGNIZER_HEADER_COMPLETION_CAUSE);
-
</del><span class="cx">         if(!recognizer->decoder || ps_start_utt(recognizer->decoder, NULL) < 0) {
</span><span class="cx">                 response->start_line.status_code = MRCP_STATUS_CODE_METHOD_FAILED;
</span><span class="cx">                 response_recog_header->completion_cause = RECOGNIZER_COMPLETION_CAUSE_ERROR;
</span><ins>+                mrcp_resource_header_property_add(response,RECOGNIZER_HEADER_COMPLETION_CAUSE);
</ins><span class="cx">                 return FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -755,17 +749,6 @@
</span><span class="cx">         }
</span><span class="cx">         while(recognizer->close_requested == FALSE);
</span><span class="cx">
</span><del>-        /* check if recognition is still active */
-        if(recognizer->inprogress_recog) {
-                apr_thread_mutex_lock(recognizer->mutex);
-                recognizer->stop_response = recognizer->inprogress_recog;
-                apr_thread_cond_wait(recognizer->wait_object,recognizer->mutex);
-                apr_thread_mutex_unlock(recognizer->mutex);
-                if(recognizer->complete_event) {
-                        pocketsphinx_recognition_complete(recognizer,recognizer->complete_event);
-                }
-        }
-
</del><span class="cx">         /** Clear all the defined grammars */
</span><span class="cx">         pocketsphinx_grammars_clear(recognizer);
</span><span class="cx">         
</span><span class="lines">@@ -776,6 +759,10 @@
</span><span class="cx">                 recognizer->decoder = NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        recognizer->thread = NULL;
+        /** Finally send response to channel_close request */
+        mrcp_engine_channel_close_respond(recognizer->channel);
+
</ins><span class="cx">         /** Exit thread */
</span><span class="cx">         apr_thread_exit(thread,APR_SUCCESS);
</span><span class="cx">         return NULL;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>