bool SynthSession::OnMessageReceive(mrcp_channel_t* pMrcpChannel, mrcp_message_t* pMrcpMessage) { if(!UmcSession::OnMessageReceive(pMrcpChannel,pMrcpMessage)) return false; if(pMrcpMessage->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) { /* received MRCP response */ if(pMrcpMessage->start_line.method_id == SYNTHESIZER_SPEAK) { /* received the response to SPEAK request */ if(pMrcpMessage->start_line.request_state == MRCP_REQUEST_STATE_INPROGRESS) { SynthChannel* pSynthChannel = (SynthChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pSynthChannel) pSynthChannel->m_pSpeakRequest = GetMrcpMessage(); /* waiting for SPEAK-COMPLETE event */ } else { /* received unexpected response, terminate the session */ Terminate(); } } else { /* received unexpected response */ } } else if(pMrcpMessage->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) { /* received MRCP event */ if(pMrcpMessage->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) { SynthChannel* pSynthChannel = (SynthChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pSynthChannel) pSynthChannel->m_pSpeakRequest = NULL; /* received SPEAK-COMPLETE event, terminate the session */ Terminate(); } } return true; }
bool VerifierSession::OnMessageReceive(mrcp_channel_t* pMrcpChannel, mrcp_message_t* pMrcpMessage) { if(!UmcSession::OnMessageReceive(pMrcpChannel,pMrcpMessage)) return false; VerifierChannel* pVerifierChannel = (VerifierChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pMrcpMessage->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) { /* received MRCP response */ if(pMrcpMessage->start_line.method_id == VERIFIER_START_SESSION) { /* received the response to START-SESSION request */ /* create and send VERIFY request */ mrcp_message_t* pMrcpMessage = CreateVerificationRequest(pMrcpChannel); if(pMrcpMessage) { SendMrcpRequest(pVerifierChannel->m_pMrcpChannel,pMrcpMessage); } } else if(pMrcpMessage->start_line.method_id == VERIFIER_END_SESSION) { /* received the response to END-SESSION request */ Terminate(); } else if(pMrcpMessage->start_line.method_id == VERIFIER_VERIFY) { /* received the response to VERIFY request */ if(pMrcpMessage->start_line.request_state == MRCP_REQUEST_STATE_INPROGRESS) { VerifierChannel* pVerifierChannel = (VerifierChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pVerifierChannel) pVerifierChannel->m_pVerificationRequest = GetMrcpMessage(); /* start to stream the speech to Verify */ if(pVerifierChannel) pVerifierChannel->m_Streaming = true; } else { /* create and send END-SESSION request */ mrcp_message_t* pMrcpMessage = CreateEndSessionRequest(pMrcpChannel); if(pMrcpMessage) { SendMrcpRequest(pVerifierChannel->m_pMrcpChannel,pMrcpMessage); } } } else { /* received unexpected response */ } } else if(pMrcpMessage->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) { if(pMrcpMessage->start_line.method_id == VERIFIER_VERIFICATION_COMPLETE) { if(pVerifierChannel) pVerifierChannel->m_Streaming = false; VerifierChannel* pVerifierChannel = (VerifierChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pVerifierChannel) pVerifierChannel->m_pVerificationRequest = NULL; /* create and send END-SESSION request */ mrcp_message_t* pMrcpMessage = CreateEndSessionRequest(pMrcpChannel); if(pVerifierChannel && pMrcpMessage) { SendMrcpRequest(pVerifierChannel->m_pMrcpChannel,pMrcpMessage); } } else if(pMrcpMessage->start_line.method_id == VERIFIER_START_OF_INPUT) { /* received start-of-input, do whatever you need here */ } } return true; }
bool RecogSession::OnMessageReceive(mrcp_channel_t* pMrcpChannel, mrcp_message_t* pMrcpMessage) { if(!UmcSession::OnMessageReceive(pMrcpChannel,pMrcpMessage)) return false; RecogChannel* pRecogChannel = (RecogChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pMrcpMessage->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) { /* received MRCP response */ if(pMrcpMessage->start_line.method_id == RECOGNIZER_DEFINE_GRAMMAR) { /* received the response to DEFINE-GRAMMAR request */ if(pMrcpMessage->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) { OnDefineGrammar(pMrcpChannel); } else { /* received unexpected response, terminate the session */ Terminate(); } } else if(pMrcpMessage->start_line.method_id == RECOGNIZER_RECOGNIZE) { /* received the response to RECOGNIZE request */ if(pMrcpMessage->start_line.request_state == MRCP_REQUEST_STATE_INPROGRESS) { RecogChannel* pRecogChannel = (RecogChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pRecogChannel) pRecogChannel->m_pRecogRequest = GetMrcpMessage(); /* start to stream the speech to recognize */ if(pRecogChannel) pRecogChannel->m_Streaming = true; } else { /* received unexpected response, terminate the session */ Terminate(); } } else { /* received unexpected response */ } } else if(pMrcpMessage->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) { if(pMrcpMessage->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) { ParseNLSMLResult(pMrcpMessage); if(pRecogChannel) pRecogChannel->m_Streaming = false; RecogChannel* pRecogChannel = (RecogChannel*) mrcp_application_channel_object_get(pMrcpChannel); if(pRecogChannel) pRecogChannel->m_pRecogRequest = NULL; Terminate(); } else if(pMrcpMessage->start_line.method_id == RECOGNIZER_START_OF_INPUT) { /* received start-of-input, do whatever you need here */ } } return true; }