/* Get speech channel associated with provided MRCP session. */ static APR_INLINE speech_channel_t * get_speech_channel(mrcp_session_t *session) { if (session) return (speech_channel_t *)mrcp_application_session_object_get(session); return NULL; }
/** \brief Received session termination response */ static apt_bool_t on_session_terminate(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status) { struct ast_speech *speech = mrcp_application_session_object_get(session); uni_speech_t *uni_speech = speech->data; ast_log(LOG_DEBUG, "On session terminate\n"); return uni_recog_sm_response_signal(uni_speech,MRCP_SIG_COMMAND_SESSION_TERMINATE,status); }
/** \brief Received session update response */ static apt_bool_t on_session_update(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status) { struct ast_speech *speech = mrcp_application_session_object_get(session); uni_speech_t *uni_speech = speech->data; ast_log(LOG_DEBUG, "(%s) Session updated status: %d\n",uni_speech->name, status); return uni_recog_sm_response_signal(uni_speech,MRCP_SIG_COMMAND_SESSION_UPDATE,status); }
apt_bool_t AppOnSessionTerminate(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status) { UmcSession* pSession = (UmcSession*) mrcp_application_session_object_get(session); if(!pSession->OnSessionTerminate(status)) return false; UmcFramework* pFramework = (UmcFramework*) mrcp_application_object_get(application); pFramework->RemoveSession(pSession); delete pSession; return true; }
/** Application message handler */ static apt_bool_t app_message_handler(const mrcp_app_message_t *app_message) { if((app_message->message_type == MRCP_APP_MESSAGE_TYPE_SIGNALING && app_message->sig_message.message_type == MRCP_SIG_MESSAGE_TYPE_RESPONSE) || app_message->message_type == MRCP_APP_MESSAGE_TYPE_CONTROL) { asr_session_t *asr_session = mrcp_application_session_object_get(app_message->session); if(asr_session) { apr_thread_mutex_lock(asr_session->mutex); asr_session->app_message = app_message; apr_thread_cond_signal(asr_session->wait_object); apr_thread_mutex_unlock(asr_session->mutex); } } return TRUE; }
/* Handle the UniMRCP responses sent to session terminate requests. */ static apt_bool_t speech_on_session_terminate(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status) { speech_channel_t *schannel; if (session != NULL) schannel = (speech_channel_t *)mrcp_application_session_object_get(session); else schannel = NULL; ast_log(LOG_DEBUG, "(%s) speech_on_session_terminate\n", schannel->name); if (schannel != NULL) { ast_log(LOG_DEBUG, "(%s) Destroying MRCP session\n", schannel->name); if (!mrcp_application_session_destroy(session)) ast_log(LOG_WARNING, "(%s) Unable to destroy application session\n", schannel->name); speech_channel_set_state(schannel, SPEECH_CHANNEL_CLOSED); } else ast_log(LOG_ERROR, "(unknown) channel error!\n"); return TRUE; }
apt_bool_t AppOnResourceDiscover(mrcp_application_t *application, mrcp_session_t *session, mrcp_session_descriptor_t *descriptor, mrcp_sig_status_code_e status) { UmcSession* pSession = (UmcSession*) mrcp_application_session_object_get(session); return pSession->OnResourceDiscover(descriptor,status); }
apt_bool_t AppOnTerminateEvent(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel) { UmcSession* pSession = (UmcSession*) mrcp_application_session_object_get(session); return pSession->OnTerminateEvent(channel); }
apt_bool_t AppOnMessageReceive(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message) { UmcSession* pSession = (UmcSession*) mrcp_application_session_object_get(session); return pSession->OnMessageReceive(channel,message); }
apt_bool_t AppOnChannelRemove(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status) { UmcSession* pSession = (UmcSession*) mrcp_application_session_object_get(session); return pSession->OnChannelRemove(channel,status); }
apt_bool_t AppOnSessionUpdate(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status) { UmcSession* pSession = (UmcSession*) mrcp_application_session_object_get(session); return pSession->OnSessionUpdate(status); }
apt_bool_t AppOnResourceDiscover(mrcp_application_t* pApplication, mrcp_session_t* pSession, mrcp_session_descriptor_t* pDescriptor, mrcp_sig_status_code_e status) { UmcSessionEventHandler* pEventHandler = (UmcSessionEventHandler*) mrcp_application_session_object_get(pSession); return pEventHandler->OnResourceDiscover(pDescriptor,status); }
apt_bool_t AppOnTerminateEvent(mrcp_application_t* pApplication, mrcp_session_t* pSession, mrcp_channel_t* pChannel) { UmcSessionEventHandler* pEventHandler = (UmcSessionEventHandler*) mrcp_application_session_object_get(pSession); return pEventHandler->OnTerminateEvent(pChannel); }
apt_bool_t AppOnMessageReceive(mrcp_application_t* pApplication, mrcp_session_t* pSession, mrcp_channel_t* pChannel, mrcp_message_t* pMessage) { UmcSessionEventHandler* pEventHandler = (UmcSessionEventHandler*) mrcp_application_session_object_get(pSession); return pEventHandler->OnMessageReceive(pChannel,pMessage); }
apt_bool_t AppOnChannelRemove(mrcp_application_t* pApplication, mrcp_session_t* pSession, mrcp_channel_t* pChannel, mrcp_sig_status_code_e status) { UmcSessionEventHandler* pEventHandler = (UmcSessionEventHandler*) mrcp_application_session_object_get(pSession); return pEventHandler->OnChannelRemove(pChannel,status); }
apt_bool_t AppOnSessionTerminate(mrcp_application_t* pApplication, mrcp_session_t* pSession, mrcp_sig_status_code_e status) { UmcSessionEventHandler* pEventHandler = (UmcSessionEventHandler*) mrcp_application_session_object_get(pSession); return pEventHandler->OnSessionTerminate(status); }