Ejemplo n.º 1
0
/** 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->resource,
						source->start_line.version,
						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 "APT_SIDRES_FMT" [%"MRCP_REQUEST_ID_FMT"]",
		MRCP_MESSAGE_SIDRES(message),
		message->start_line.request_id);
	return recog_request_dispatch(state_machine,message);
}
Ejemplo n.º 2
0
/* Create SPEAK request */
static mrcp_message_t* speak_request_create(mrcp_resource_factory_t *factory, apr_pool_t *pool)
{
    mrcp_message_t *message;
    mrcp_resource_t *resource = mrcp_resource_get(factory,MRCP_SYNTHESIZER_RESOURCE);
    if(!resource) {
        return NULL;
    }
    apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create SPEAK Request");
    message = mrcp_request_create(resource,MRCP_VERSION_2,SYNTHESIZER_SPEAK,pool);
    if(message) {
        mrcp_generic_header_t *generic_header;
        mrcp_synth_header_t *synth_header;
        /* get/allocate generic header */
        generic_header = mrcp_generic_header_prepare(message);
        if(generic_header) {
            /* set generic header fields */
            apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Content-Type: %s",SAMPLE_CONTENT_TYPE);
            apt_string_assign(&generic_header->content_type,SAMPLE_CONTENT_TYPE,message->pool);
            mrcp_generic_header_property_add(message,GENERIC_HEADER_CONTENT_TYPE);
        }
        /* get/allocate synthesizer header */
        synth_header = mrcp_resource_header_prepare(message);
        if(synth_header) {
            /* set synthesizer header fields */
            apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Voice-Age: %d",SAMPLE_VOICE_AGE);
            synth_header->voice_param.age = SAMPLE_VOICE_AGE;
            mrcp_resource_header_property_add(message,SYNTHESIZER_HEADER_VOICE_AGE);
        }
        /* set message body */
        apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Body: %s",SAMPLE_CONTENT);
        apt_string_assign(&message->body,SAMPLE_CONTENT,message->pool);
    }
    return message;
}
/* Create SPEAK request */
static mrcp_message_t* speak_request_create(mrcp_resource_factory_t *factory, apr_pool_t *pool)
{
	mrcp_message_t *message;
	mrcp_resource_t *resource = mrcp_resource_get(factory,MRCP_SYNTHESIZER_RESOURCE);
	if(!resource) {
		return NULL;
	}
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create SPEAK Request");
	message = mrcp_request_create(resource,MRCP_VERSION_2,SYNTHESIZER_SPEAK,pool);
	if(message) {
		/* set transparent header fields */
		apt_header_field_t *header_field;
		header_field = apt_header_field_create_c("Content-Type",SAMPLE_CONTENT_TYPE,message->pool);
		if(header_field) {
			apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set %s: %s",header_field->name.buf,header_field->value.buf);
			mrcp_message_header_field_add(message,header_field);
		}

		header_field = apt_header_field_create_c("Voice-Age",SAMPLE_VOICE_AGE,message->pool);
		if(header_field) {
			apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set %s: %s",header_field->name.buf,header_field->value.buf);
			mrcp_message_header_field_add(message,header_field);
		}

		/* set message body */
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Body: %s",SAMPLE_CONTENT);
		apt_string_assign(&message->body,SAMPLE_CONTENT,message->pool);
	}
	return message;
}
/* Create GET-PARAMS request */
static mrcp_message_t* get_params_request_create(mrcp_resource_factory_t *factory, apr_pool_t *pool)
{
	mrcp_message_t *message;
	mrcp_resource_t *resource = mrcp_resource_get(factory,MRCP_SYNTHESIZER_RESOURCE);
	if(!resource) {
		return NULL;
	}
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create GET-PARAMS Request");
	message = mrcp_request_create(resource,MRCP_VERSION_2,SYNTHESIZER_GET_PARAMS,pool);
	if(message) {
		apt_header_field_t *header_field;
		header_field = apt_header_field_create_c("Content-Id","",message->pool);
		if(header_field) {
			apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set %s:",header_field->name.buf);
			mrcp_message_header_field_add(message,header_field);
		}
		header_field = apt_header_field_create_c("Vendor-Specific-Params",SAMPLE_PARAM_NAME,message->pool);
		if(header_field) {
			apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set %s:",header_field->name.buf);
			mrcp_message_header_field_add(message,header_field);
		}
		header_field = apt_header_field_create_c("Voice-Age","",message->pool);
		if(header_field) {
			apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set %s:",header_field->name.buf);
			mrcp_message_header_field_add(message,header_field);
		}
	}
	return message;
}
Ejemplo n.º 5
0
/** 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->resource,
                  source->start_line.version,
                  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 [%"MRCP_REQUEST_ID_FMT"]",
            message->start_line.request_id);
    return synth_request_dispatch(state_machine,message);
}
Ejemplo n.º 6
0
/** Create MRCP message */
mrcp_message_t* mrcp_application_message_create(mrcp_session_t *session, mrcp_channel_t *channel, mrcp_method_id method_id)
{
	mrcp_message_t *mrcp_message;
	mrcp_profile_t *profile;
	mrcp_client_session_t *client_session = (mrcp_client_session_t*)session;
	if(!client_session || !channel) {
		return NULL;
	}
	profile = client_session->profile;
	if(!profile || !profile->resource_factory) {
		return NULL;
	}
	mrcp_message = mrcp_request_create(channel->resource_id,method_id,session->pool);
	if(mrcp_message) {
		mrcp_message->start_line.version = profile->signaling_agent->mrcp_version;
		mrcp_message_resourcify_by_id(profile->resource_factory,mrcp_message);
	}
	return mrcp_message;
}
Ejemplo n.º 7
0
/** Create MRCP message */
MRCP_DECLARE(mrcp_message_t*) mrcp_application_message_create(mrcp_session_t *session, mrcp_channel_t *channel, mrcp_method_id method_id)
{
	mrcp_message_t *mrcp_message;
	mrcp_profile_t *profile;
	mrcp_client_session_t *client_session = (mrcp_client_session_t*)session;
	if(!client_session || !channel || !channel->resource) {
		return NULL;
	}
	profile = client_session->profile;
	if(!profile || !profile->resource_factory) {
		return NULL;
	}
	mrcp_message = mrcp_request_create(
						channel->resource,
						profile->mrcp_version,
						method_id,
						session->pool);
	return mrcp_message;
}
Ejemplo n.º 8
0
/* Create GET-PARAMS request */
static mrcp_message_t* get_params_request_create(mrcp_resource_factory_t *factory, apr_pool_t *pool)
{
    mrcp_message_t *message;
    mrcp_resource_t *resource = mrcp_resource_get(factory,MRCP_SYNTHESIZER_RESOURCE);
    if(!resource) {
        return NULL;
    }
    apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create GET-PARAMS Request");
    message = mrcp_request_create(resource,MRCP_VERSION_2,SYNTHESIZER_GET_PARAMS,pool);
    if(message) {
        apt_str_t param_name;
        apt_str_t param_value;
        mrcp_generic_header_t *generic_header;
        mrcp_synth_header_t *synth_header;
        /* get/allocate generic header */
        generic_header = mrcp_generic_header_prepare(message);
        if(generic_header) {
            /* set content id empty header */
            apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Content-ID: <empty>");
            mrcp_generic_header_name_property_add(message,GENERIC_HEADER_CONTENT_ID);

            /* set vendor specific params header */
            generic_header->vendor_specific_params = apt_pair_array_create(1,pool);
            apt_string_set(&param_name,SAMPLE_PARAM_NAME);
            apt_string_reset(&param_value);
            apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Vendor-Specific-Params: %s",param_name.buf);
            apt_pair_array_append(generic_header->vendor_specific_params,&param_name,&param_value,pool);
            mrcp_generic_header_property_add(message,GENERIC_HEADER_VENDOR_SPECIFIC_PARAMS);
        }
        /* get/allocate synthesizer header */
        synth_header = mrcp_resource_header_prepare(message);
        if(synth_header) {
            /* set voice age empty header */
            apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Set Voice-Age: <empty>");
            mrcp_resource_header_name_property_add(message,SYNTHESIZER_HEADER_VOICE_AGE);
        }
    }
    return message;
}