Пример #1
0
bool SynthSession::OnChannelAdd(mrcp_channel_t* pMrcpChannel, mrcp_sig_status_code_e status)
{
	if(!UmcSession::OnChannelAdd(pMrcpChannel,status))
		return false;

	const mpf_codec_descriptor_t* pDescriptor = mrcp_application_sink_descriptor_get(pMrcpChannel);
	if(!pDescriptor) 
	{
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Sink Descriptor");
		return Terminate();
	}

	SynthChannel* pSynthChannel = (SynthChannel*) mrcp_application_channel_object_get(pMrcpChannel);
	if(status != MRCP_SIG_STATUS_CODE_SUCCESS)
	{
		/* error case, just terminate the demo */
		return Terminate();
	}

	/* create MRCP message */
	mrcp_message_t* pMrcpMessage = CreateSpeakRequest(pMrcpChannel);
	if(pMrcpMessage) 
	{
		SendMrcpRequest(pSynthChannel->m_pMrcpChannel,pMrcpMessage);
	}

	pSynthChannel->m_pAudioOut = GetAudioOut(pDescriptor,GetSessionPool());
	return true;
}
Пример #2
0
bool VerifierSession::StartVerification(mrcp_channel_t* pMrcpChannel)
{
	const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
	if(!pDescriptor)
	{
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Source Descriptor");
		return Terminate();
	}

	VerifierChannel* pVerifierChannel = (VerifierChannel*) mrcp_application_channel_object_get(pMrcpChannel);
	/* create and send Verification request */
	mrcp_message_t* pMrcpMessage = CreateStartSessionRequest(pMrcpChannel);
	if(pMrcpMessage)
	{
		SendMrcpRequest(pVerifierChannel->m_pMrcpChannel,pMrcpMessage);
	}

	pVerifierChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
	if(!pVerifierChannel->m_pAudioIn)
	{
		/* no audio input availble, set some estimated time to complete instead */
		pVerifierChannel->m_TimeToComplete = 5000; // 5 sec
	}
	return true;
}
Пример #3
0
bool SetParamSession::CreateRequestQueue(mrcp_channel_t* pMrcpChannel)
{
    m_CurrentRequest = 0;
    m_RequestQueue = apr_array_make(GetSessionPool(),5,sizeof(mrcp_message_t*));
    mrcp_message_t* pMrcpMessage;

    pMrcpMessage = CreateSetParams1(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateGetParams1(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateSetParams2(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateGetParams2(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateSetParams3(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateGetParams3(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    return true;
}
Пример #4
0
bool RecorderSession::StartRecorder(mrcp_channel_t* pMrcpChannel)
{
	RecorderChannel* pRecorderChannel = (RecorderChannel*) mrcp_application_channel_object_get(pMrcpChannel);
	/* create and send RECORD request */
	mrcp_message_t* pMrcpMessage = CreateRecordRequest(pMrcpChannel);
	if(pMrcpMessage)
	{
		SendMrcpRequest(pRecorderChannel->m_pMrcpChannel,pMrcpMessage);
	}

	const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
	pRecorderChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
	return true;
}
Пример #5
0
mrcp_message_t* SetParamSession::CreateSetParams3(mrcp_channel_t* pMrcpChannel)
{
    mrcp_message_t* pMrcpMessage = CreateMrcpMessage(pMrcpChannel,RECOGNIZER_SET_PARAMS);
    if(!pMrcpMessage)
        return NULL;

    mrcp_generic_header_t* pGenericHeader;
    /* get/allocate generic header */
    pGenericHeader = (mrcp_generic_header_t*) mrcp_generic_header_prepare(pMrcpMessage);
    if(pGenericHeader)
    {
        apr_pool_t* pool = GetSessionPool();
        /* set generic header fields */
        apt_pair_arr_t* pVSP = apt_pair_array_create(3,pool);
        if(pVSP)
        {
            apt_str_t name;
            apt_str_t value;

            apt_string_set(&name,"confidencelevel");
            apt_string_set(&value,"500");
            apt_pair_array_append(pVSP,&name,&value,pool);

            apt_string_set(&name,"sensitivity");
            apt_string_set(&value,"0.500");
            apt_pair_array_append(pVSP,&name,&value,pool);

            apt_string_set(&name,"speedvsaccuracy");
            apt_string_set(&value,"0.789");
            apt_pair_array_append(pVSP,&name,&value,pool);

            apt_string_set(&name,"timeout");
            apt_string_set(&value,"1000");
            apt_pair_array_append(pVSP,&name,&value,pool);

            apt_string_set(&name,"swirec_application_name");
            apt_string_set(&value,"UniMRCP");
            apt_pair_array_append(pVSP,&name,&value,pool);

            apt_string_set(&name,"swirec_phoneme_lookahead_beam");
            apt_string_set(&value,"-50");
            apt_pair_array_append(pVSP,&name,&value,pool);

            pGenericHeader->vendor_specific_params = pVSP;
            mrcp_generic_header_property_add(pMrcpMessage,GENERIC_HEADER_VENDOR_SPECIFIC_PARAMS);
        }
    }

    return pMrcpMessage;
}
Пример #6
0
RecogChannel* RecogSession::CreateRecogChannel()
{
	mrcp_channel_t* pChannel;
	mpf_termination_t* pTermination;
	mpf_stream_capabilities_t* pCapabilities;
	apr_pool_t* pool = GetSessionPool();

	/* create channel */
	RecogChannel *pRecogChannel = new RecogChannel;
	pRecogChannel->m_pMrcpChannel = NULL;
	pRecogChannel->m_Streaming = false;
	pRecogChannel->m_pAudioIn = NULL;
	pRecogChannel->m_TimeToComplete = 0;

	/* create source stream capabilities */
	pCapabilities = mpf_source_stream_capabilities_create(pool);
	GetScenario()->InitCapabilities(pCapabilities);

	static const mpf_audio_stream_vtable_t audio_stream_vtable = 
	{
		NULL,
		NULL,
		NULL,
		ReadStream,
		NULL,
		NULL,
		NULL
	};

	pTermination = CreateAudioTermination(
			&audio_stream_vtable,      /* virtual methods table of audio stream */
			pCapabilities,             /* capabilities of audio stream */
			pRecogChannel);            /* object to associate */

	pChannel = CreateMrcpChannel(
			MRCP_RECOGNIZER_RESOURCE,  /* MRCP resource identifier */
			pTermination,              /* media termination, used to terminate audio stream */
			NULL,                      /* RTP descriptor, used to create RTP termination (NULL by default) */
			pRecogChannel);            /* object to associate */
	if(!pChannel)
	{
		delete pRecogChannel;
		return NULL;
	}
	
	pRecogChannel->m_pMrcpChannel = pChannel;
	return pRecogChannel;
}
Пример #7
0
SynthChannel* SynthSession::CreateSynthChannel()
{
	mrcp_channel_t* pChannel;
	mpf_termination_t* pTermination;
	mpf_stream_capabilities_t* pCapabilities;
	apr_pool_t* pool = GetSessionPool();

	/* create channel */
	SynthChannel* pSynthChannel = new SynthChannel;

	/* create sink stream capabilities */
	pCapabilities = mpf_sink_stream_capabilities_create(pool);
	GetScenario()->InitCapabilities(pCapabilities);

	static const mpf_audio_stream_vtable_t audio_stream_vtable = 
	{
		NULL,
		NULL,
		NULL,
		NULL,
		NULL,
		NULL,
		WriteStream,
		NULL
	};

	pTermination = CreateAudioTermination(
			&audio_stream_vtable,      /* virtual methods table of audio stream */
			pCapabilities,             /* capabilities of audio stream */
			pSynthChannel);            /* object to associate */
	
	pChannel = CreateMrcpChannel(
			MRCP_SYNTHESIZER_RESOURCE, /* MRCP resource identifier */
			pTermination,              /* media termination, used to terminate audio stream */
			NULL,                      /* RTP descriptor, used to create RTP termination (NULL by default) */
			pSynthChannel);            /* object to associate */
	if(!pChannel)
	{
		delete pSynthChannel;
		return NULL;
	}

	pSynthChannel->m_pMrcpChannel = pChannel;
	return pSynthChannel;
}
Пример #8
0
bool RecogSession::StartRecognition(mrcp_channel_t* pMrcpChannel)
{
	RecogChannel* pRecogChannel = (RecogChannel*) mrcp_application_channel_object_get(pMrcpChannel);
	/* create and send RECOGNIZE request */
	mrcp_message_t* pMrcpMessage = CreateRecognizeRequest(pMrcpChannel);
	if(pMrcpMessage)
	{
		SendMrcpRequest(pRecogChannel->m_pMrcpChannel,pMrcpMessage);
	}

	const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
	pRecogChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
	if(!pRecogChannel->m_pAudioIn)
	{
		/* no audio input availble, set some estimated time to complete instead */
		pRecogChannel->m_TimeToComplete = 5000; // 5 sec
	}
	return true;
}
Пример #9
0
bool RecorderSession::StartRecorder(mrcp_channel_t* pMrcpChannel)
{
	const mpf_codec_descriptor_t* pDescriptor = mrcp_application_source_descriptor_get(pMrcpChannel);
	if(!pDescriptor)
	{
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Get Media Source Descriptor");
		return Terminate();
	}

	RecorderChannel* pRecorderChannel = (RecorderChannel*) mrcp_application_channel_object_get(pMrcpChannel);
	/* create and send RECORD request */
	mrcp_message_t* pMrcpMessage = CreateRecordRequest(pMrcpChannel);
	if(pMrcpMessage)
	{
		SendMrcpRequest(pRecorderChannel->m_pMrcpChannel,pMrcpMessage);
	}

	pRecorderChannel->m_pAudioIn = GetAudioIn(pDescriptor,GetSessionPool());
	return true;
}
Пример #10
0
bool DtmfSession::OnChannelAdd(mrcp_channel_t* pMrcpChannel, mrcp_sig_status_code_e status)
{
	if(!UmcSession::OnChannelAdd(pMrcpChannel,status))
		return false;

	if(status != MRCP_SIG_STATUS_CODE_SUCCESS)
	{
		/* error case, just terminate the demo */
		return Terminate();
	}

	RecogChannel* pRecogChannel = (RecogChannel*) mrcp_application_channel_object_get(pMrcpChannel);
	if(pRecogChannel)
	{
		const mpf_audio_stream_t* pStream = mrcp_application_audio_stream_get(pMrcpChannel);
		if(pStream)
		{
			pRecogChannel->m_pDtmfGenerator = mpf_dtmf_generator_create(pStream,GetSessionPool());
		}
	}

	return StartRecognition(pMrcpChannel);
}