static apt_bool_t mrcp_app_control_message_raise(mrcp_client_session_t *session, mrcp_channel_t *channel, mrcp_message_t *mrcp_message)
{
	if(mrcp_message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
		mrcp_app_message_t *response;
		mrcp_message_t *mrcp_request;
		if(!session->active_request || !session->active_request->control_message) {
			return FALSE;
		}
		response = mrcp_client_app_response_create(session->active_request,0,session->base.pool);
		mrcp_request = session->active_request->control_message;
		mrcp_message->start_line.method_id = mrcp_request->start_line.method_id;
		mrcp_message->start_line.method_name = mrcp_request->start_line.method_name;
		response->control_message = mrcp_message;
		apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Raise App MRCP Response "APT_NAMESID_FMT, 
			MRCP_SESSION_NAMESID(session));
		session->application->handler(response);

		session->active_request = apt_list_pop_front(session->request_queue);
		if(session->active_request) {
			mrcp_app_request_dispatch(session,session->active_request);
		}
	}
	else if(mrcp_message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
		mrcp_app_message_t *app_message;
		app_message = mrcp_client_app_control_message_create(session->base.pool);
		app_message->control_message = mrcp_message;
		app_message->application = session->application;
		app_message->session = &session->base;
		app_message->channel = channel;
		apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Raise App MRCP Event "APT_NAMESID_FMT, 
			MRCP_SESSION_NAMESID(session));
		session->application->handler(app_message);
	}
	return TRUE;
}
예제 #2
0
static apt_bool_t mrcp_app_control_message_raise(mrcp_client_session_t *session, mrcp_channel_t *channel, mrcp_message_t *mrcp_message)
{
	if(mrcp_message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
		mrcp_app_message_t *response;
		mrcp_message_t *mrcp_request;
		if(!session->active_request || !session->active_request->control_message) {
			return FALSE;
		}
		response = apr_palloc(session->base.pool,sizeof(mrcp_app_message_t));
		*response = *session->active_request;
		mrcp_request = session->active_request->control_message;
		mrcp_message->start_line.method_id = mrcp_request->start_line.method_id;
		mrcp_message->start_line.method_name = mrcp_request->start_line.method_name;
		response->control_message = mrcp_message;
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Raise App MRCP Response <%s>", mrcp_session_str(session));
		session->application->handler(response);

		session->active_request = apt_list_pop_front(session->request_queue);
		if(session->active_request) {
			mrcp_app_request_dispatch(session,session->active_request);
		}
	}
	else if(mrcp_message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
		mrcp_app_message_t *app_message;
		app_message = apr_palloc(session->base.pool,sizeof(mrcp_app_message_t));
		app_message->message_type = MRCP_APP_MESSAGE_TYPE_CONTROL;
		app_message->control_message = mrcp_message;
		app_message->application = session->application;
		app_message->session = &session->base;
		app_message->channel = channel;
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Raise App MRCP Event <%s>", mrcp_session_str(session));
		session->application->handler(app_message);
	}
	return TRUE;
}
예제 #3
0
static apt_bool_t mrcp_app_sig_response_raise(mrcp_client_session_t *session, mrcp_sig_status_code_e status, apt_bool_t process_pending_requests)
{
	mrcp_app_message_t *response;
	if(!session->active_request) {
		return FALSE;
	}
	response = apr_palloc(session->base.pool,sizeof(mrcp_app_message_t));
	*response = *session->active_request;
	response->sig_message.message_type = MRCP_SIG_MESSAGE_TYPE_RESPONSE;
	response->sig_message.status = status;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Raise App Response <%s> [%d] %s [%d]", 
		mrcp_session_str(session),
		response->sig_message.command_id,
		status == MRCP_SIG_STATUS_CODE_SUCCESS ? "SUCCESS" : "FAILURE",
		status);
	session->application->handler(response);

	if(process_pending_requests) {
		session->active_request = apt_list_pop_front(session->request_queue);
		if(session->active_request) {
			mrcp_app_request_dispatch(session,session->active_request);
		}
	}
	else {
		session->active_request = NULL;
	}
	return TRUE;
}
예제 #4
0
static apt_bool_t mrcp_app_sig_response_raise(mrcp_client_session_t *session, apt_bool_t process_pending_requests)
{
	mrcp_app_message_t *response;
	const mrcp_app_message_t *request = session->active_request;
	if(!request) {
		return FALSE;
	}
	session->active_request = NULL;
	if(session->disconnected == TRUE) {
		session->status = MRCP_SIG_STATUS_CODE_TERMINATE;
	}
	response = mrcp_client_app_response_create(request,session->status,session->base.pool);
	apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Raise App Response " APT_NAMESID_FMT " [%d] %s [%d]", 
		MRCP_SESSION_NAMESID(session),
		response->sig_message.command_id,
		session->status == MRCP_SIG_STATUS_CODE_SUCCESS ? "SUCCESS" : "FAILURE",
		session->status);
	session->application->handler(response);

	if(process_pending_requests) {
		session->active_request = apt_list_pop_front(session->request_queue);
		if(session->active_request) {
			mrcp_app_request_dispatch(session,session->active_request);
		}
	}
	return TRUE;
}
apt_bool_t mrcp_client_session_terminate_event_process(mrcp_client_session_t *session)
{
	if(session->state == SESSION_STATE_TERMINATING) {
		/* session termination request has been sent, still waiting for the response,
		   all the events must be ignored at this stage */
		apt_obj_log(APT_LOG_MARK,APT_PRIO_WARNING,session->base.log_obj,"Unexpected Event! "APT_NAMESID_FMT, 
			MRCP_SESSION_NAMESID(session));
		return FALSE;
	}
	
	if(session->active_request) {
		apt_bool_t process_pending_requests = TRUE;
		/* raise app response */
		session->status = MRCP_SIG_STATUS_CODE_TERMINATE;
		mrcp_app_failure_message_raise(session);

		/* cancel remaing requests, but do process session termination request (if any) */
		do {
			session->active_request = apt_list_pop_front(session->request_queue);
			if(session->active_request) {
				const mrcp_app_message_t *app_message = session->active_request;
				if(app_message->message_type == MRCP_APP_MESSAGE_TYPE_SIGNALING &&
					app_message->sig_message.command_id == MRCP_SIG_COMMAND_SESSION_TERMINATE) {
					/* process session termination */
					mrcp_app_request_dispatch(session,app_message);
					break;
				}

				/* cancel pending request */
				session->status = MRCP_SIG_STATUS_CODE_CANCEL;
				mrcp_app_failure_message_raise(session);
			}
			else {
				process_pending_requests = FALSE;
			}
		}
		while(process_pending_requests == TRUE);
	}
	else {
		/* raise app event */
		mrcp_app_sig_event_raise(session,NULL);
	}
	return TRUE;
}
apt_bool_t mrcp_client_session_discover_response_process(mrcp_client_session_t *session, mrcp_session_descriptor_t *descriptor)
{
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Resources Discovered %s", session->base.name);
	if(!session->active_request) {
		return FALSE;
	}

	if(!descriptor) {
		/* raise app response */
		session->status = MRCP_SIG_STATUS_CODE_FAILURE;
		return mrcp_app_sig_response_raise(session,TRUE);
	}

	if(mrcp_session_version_get(session) == MRCP_VERSION_1) {
		if(descriptor->resource_state == TRUE) {
			mrcp_control_descriptor_t *control_media;
			if(!session->answer) {
				session->answer = descriptor;
			}
			control_media = mrcp_control_descriptor_create(session->base.pool);
			control_media->id = mrcp_session_control_media_add(session->answer,control_media);
			control_media->resource_name = descriptor->resource_name;
		}
	}
	else {
		session->answer = descriptor;
	}

	if(mrcp_client_session_subrequest_remove(session) == TRUE) {
		mrcp_app_message_t *response;
		response = mrcp_client_app_response_create(session->active_request,MRCP_SIG_STATUS_CODE_SUCCESS,session->base.pool);
		response->descriptor = session->answer;
		session->answer = NULL;
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Raise App Resource Discovery Response %s", session->base.name);
		session->application->handler(response);

		session->active_request = apt_list_pop_front(session->request_queue);
		if(session->active_request) {
			mrcp_app_request_dispatch(session,session->active_request);
		}
	}
	return TRUE;
}
예제 #7
0
apt_bool_t mrcp_client_app_message_process(mrcp_app_message_t *app_message)
{
	mrcp_client_session_t *session = (mrcp_client_session_t*)app_message->session;
	if(app_message->message_type == MRCP_APP_MESSAGE_TYPE_SIGNALING) {
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive App Request <%s> [%d]",
			mrcp_session_str(session),
			app_message->sig_message.command_id);
	}
	else {
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive App MRCP Request <%s>", mrcp_session_str(session));
	}

	if(session->active_request) {
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Push Request to Queue");
		apt_list_push_back(session->request_queue,app_message);
		return TRUE;
	}

	session->active_request = app_message;
	mrcp_app_request_dispatch(session,app_message);
	return TRUE;
}
apt_bool_t mrcp_client_app_message_process(mrcp_app_message_t *app_message)
{
	mrcp_client_session_t *session = (mrcp_client_session_t*)app_message->session;
	if(app_message->message_type == MRCP_APP_MESSAGE_TYPE_SIGNALING) {
		apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Receive App Request "APT_NAMESID_FMT" [%d]",
			MRCP_SESSION_NAMESID(session),
			app_message->sig_message.command_id);
	}
	else {
		apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Receive App MRCP Request "APT_NAMESID_FMT, 
			MRCP_SESSION_NAMESID(session));
	}

	if(session->active_request) {
		apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Push Request to Queue "APT_NAMESID_FMT, 
			MRCP_SESSION_NAMESID(session));
		apt_list_push_back(session->request_queue,app_message,session->base.pool);
		return TRUE;
	}

	session->active_request = app_message;
	mrcp_app_request_dispatch(session,app_message);
	return TRUE;
}