Exemplo n.º 1
0
static apt_bool_t mrcp_client_mpf_request_send(
						mpf_engine_t *engine, 
						mpf_command_type_e command_id,
						mpf_context_t *context, 
						mpf_termination_t *termination, 
						void *descriptor)
{
	apt_task_t *media_task;
	apt_task_msg_t *msg;
	mpf_message_t *mpf_message;
	if(!engine) {
		return FALSE;
	}
	media_task = mpf_task_get(engine);
	msg = apt_task_msg_get(media_task);
	msg->type = TASK_MSG_USER;
	mpf_message = (mpf_message_t*) msg->data;

	mpf_message->message_type = MPF_MESSAGE_TYPE_REQUEST;
	mpf_message->command_id = command_id;
	mpf_message->context = context;
	mpf_message->termination = termination;
	mpf_message->descriptor = descriptor;
	return apt_task_msg_signal(media_task,msg);
}
Exemplo n.º 2
0
static apt_bool_t mpf_engine_event_raise(mpf_termination_t *termination, int event_id, void *descriptor)
{
	apt_task_msg_t *task_msg;
	mpf_message_container_t *event_msg;
	mpf_message_t *mpf_message;
	mpf_engine_t *engine;
	engine = termination->media_engine;
	if(!engine) {
		return FALSE;
	}

	task_msg = apt_task_msg_get(engine->task);
	task_msg->type = engine->task_msg_type;
	event_msg = (mpf_message_container_t*) task_msg->data;
	mpf_message = event_msg->messages;
	event_msg->count = 1;

	mpf_message->command_id = event_id;
	mpf_message->message_type = MPF_MESSAGE_TYPE_EVENT;
	mpf_message->status_code = MPF_STATUS_CODE_SUCCESS;
	mpf_message->context = NULL;
	mpf_message->termination = termination;
	mpf_message->descriptor = descriptor;
	
	return apt_task_msg_parent_signal(engine->task,task_msg);
}
Exemplo n.º 3
0
void UmcFramework::ShowSessions()
{
	apt_task_t* pTask = apt_consumer_task_base_get(m_pTask);
	apt_task_msg_t* pTaskMsg = apt_task_msg_get(pTask);
	if(!pTaskMsg) 
		return;

	pTaskMsg->type = TASK_MSG_USER;
	pTaskMsg->sub_type = UMC_TASK_SHOW_SESSIONS_MSG;
	apt_task_msg_signal(pTask,pTaskMsg);
}
Exemplo n.º 4
0
void UmcFramework::ExitSession(UmcSession* pUmcSession)
{
	apt_task_t* pTask = apt_consumer_task_base_get(m_pTask);
	apt_task_msg_t* pTaskMsg = apt_task_msg_get(pTask);
	if(!pTaskMsg) 
		return;

	pTaskMsg->type = TASK_MSG_USER;
	pTaskMsg->sub_type = UMC_TASK_EXIT_SESSION_MSG;
	
	UmcTaskMsg* pUmcMsg = (UmcTaskMsg*) pTaskMsg->data;
	pUmcMsg->m_pSession = pUmcSession;
	apt_task_msg_signal(pTask,pTaskMsg);
}
Exemplo n.º 5
0
void UmcFramework::KillSession(const char* id)
{
	apt_task_t* pTask = apt_consumer_task_base_get(m_pTask);
	apt_task_msg_t* pTaskMsg = apt_task_msg_get(pTask);
	if(!pTaskMsg) 
		return;

	pTaskMsg->type = TASK_MSG_USER;
	pTaskMsg->sub_type = UMC_TASK_KILL_SESSION_MSG;
	
	UmcTaskMsg* pUmcMsg = (UmcTaskMsg*) pTaskMsg->data;
	strncpy(pUmcMsg->m_SessionId,id,sizeof(pUmcMsg->m_SessionId)-1);
	pUmcMsg->m_pAppMessage = NULL;
	apt_task_msg_signal(pTask,pTaskMsg);
}
Exemplo n.º 6
0
void UmcFramework::RunSession(const char* pScenarioName, const char* pProfileName)
{
	apt_task_t* pTask = apt_consumer_task_base_get(m_pTask);
	apt_task_msg_t* pTaskMsg = apt_task_msg_get(pTask);
	if(!pTaskMsg) 
		return;

	pTaskMsg->type = TASK_MSG_USER;
	pTaskMsg->sub_type = UMC_TASK_RUN_SESSION_MSG;
	UmcTaskMsg* pUmcMsg = (UmcTaskMsg*) pTaskMsg->data;
	strncpy(pUmcMsg->m_ScenarioName,pScenarioName,sizeof(pUmcMsg->m_ScenarioName)-1);
	strncpy(pUmcMsg->m_ProfileName,pProfileName,sizeof(pUmcMsg->m_ProfileName)-1);
	pUmcMsg->m_pAppMessage = NULL;
	apt_task_msg_signal(pTask,pTaskMsg);
}
Exemplo n.º 7
0
/** Run demo application */
apt_bool_t demo_framework_app_run(demo_framework_t *framework, const char *app_name, const char *profile_name)
{
	apt_task_t *task = apt_consumer_task_base_get(framework->task);
	apt_task_msg_t *task_msg = apt_task_msg_get(task);
	if(task_msg) {
		framework_task_data_t *framework_task_data = (framework_task_data_t*)task_msg->data;
		task_msg->type = TASK_MSG_USER;
		task_msg->sub_type = DEMO_CONSOLE_MSG_ID;
		framework_task_data = (framework_task_data_t*) task_msg->data;
		strcpy(framework_task_data->app_name,app_name);
		strcpy(framework_task_data->profile_name,profile_name);
		framework_task_data->app_message = NULL;
		framework_task_data->demo_application = NULL;
		apt_task_msg_signal(task,task_msg);
	}
	return TRUE;
}
Exemplo n.º 8
0
/** Signal task message */
static apt_bool_t rtsp_server_control_message_signal(
								task_msg_data_type_e type,
								rtsp_server_t *server,
								rtsp_server_session_t *session,
								rtsp_message_t *message)
{
	apt_task_t *task = apt_poller_task_base_get(server->task);
	apt_task_msg_t *task_msg = apt_task_msg_get(task);
	if(task_msg) {
		task_msg_data_t *data = (task_msg_data_t*)task_msg->data;
		data->type = type;
		data->server = server;
		data->session = session;
		data->message = message;
		apt_task_msg_signal(task,task_msg);
	}
	return TRUE;
}
Exemplo n.º 9
0
/** Signal task message */
static apt_bool_t rtsp_client_control_message_signal(
								task_msg_data_type_e type,
								rtsp_client_t *client,
								rtsp_client_session_t *session,
								rtsp_message_t *message)
{
	apt_task_t *task = apt_net_client_task_base_get(client->task);
	apt_task_msg_t *task_msg = apt_task_msg_get(task);
	if(task_msg) {
		task_msg_data_t *data = (task_msg_data_t*)task_msg->data;
		data->type = type;
		data->client = client;
		data->session = session;
		data->message = message;
		apt_task_msg_signal(task,task_msg);
	}
	return TRUE;
}
Exemplo n.º 10
0
static apt_bool_t demo_verifier_msg_signal(demo_verifier_msg_type_e type, mrcp_engine_channel_t *channel, mrcp_message_t *request)
{
	apt_bool_t status = FALSE;
	demo_verifier_channel_t *demo_channel = channel->method_obj;
	demo_verifier_engine_t *demo_engine = demo_channel->demo_engine;
	apt_task_t *task = apt_consumer_task_base_get(demo_engine->task);
	apt_task_msg_t *msg = apt_task_msg_get(task);
	if(msg) {
		demo_verifier_msg_t *demo_msg;
		msg->type = TASK_MSG_USER;
		demo_msg = (demo_verifier_msg_t*) msg->data;

		demo_msg->type = type;
		demo_msg->channel = channel;
		demo_msg->request = request;
		status = apt_task_msg_signal(task,msg);
	}
	return status;
}
Exemplo n.º 11
0
/** Signal task message */
static apt_bool_t mrcp_client_control_message_signal(
								connection_task_msg_type_e type,
								mrcp_connection_agent_t *agent,
								mrcp_control_channel_t *channel,
								mrcp_control_descriptor_t *descriptor,
								mrcp_message_t *message)
{
	apt_task_t *task = apt_poller_task_base_get(agent->task);
	apt_task_msg_t *task_msg = apt_task_msg_get(task);
	if(task_msg) {
		connection_task_msg_t *msg = (connection_task_msg_t*)task_msg->data;
		msg->type = type;
		msg->agent = agent;
		msg->channel = channel;
		msg->descriptor = descriptor;
		msg->message = message;
		apt_task_msg_signal(task,task_msg);
	}
	return TRUE;
}
Exemplo n.º 12
0
apt_bool_t AppMessageHandler(const mrcp_app_message_t* pMessage)
{
	UmcFramework* pFramework = (UmcFramework*) mrcp_application_object_get(pMessage->application);
	if(!pFramework)
		return FALSE;

	apt_task_t* pTask = apt_consumer_task_base_get(pFramework->m_pTask);
	apt_task_msg_t* pTaskMsg = apt_task_msg_get(pTask);
	if(pTaskMsg) 
	{
		pTaskMsg->type = TASK_MSG_USER;
		pTaskMsg->sub_type = UMC_TASK_CLIENT_MSG;
		
		UmcTaskMsg* pUmcMsg = (UmcTaskMsg*) pTaskMsg->data;
		pUmcMsg->m_pAppMessage = pMessage;
		apt_task_msg_signal(pTask,pTaskMsg);
	}
	
	return TRUE;
}
Exemplo n.º 13
0
static mpf_message_t* mpf_engine_message_get(mpf_engine_t *engine, mpf_task_msg_t **task_msg)
{
	mpf_message_container_t *container;
	mpf_message_t *mpf_message;
	if(*task_msg) {
		container = (mpf_message_container_t*) (*task_msg)->data;
		if(container->count >= MAX_MPF_MESSAGE_COUNT) {
			/* container has been already filled,
			implicitly send the requests and get new task message */
			mpf_engine_message_send(engine,task_msg);
			return mpf_engine_message_get(engine,task_msg);
		}
	}
	else {
		*task_msg = apt_task_msg_get(engine->task);
		container = (mpf_message_container_t*) (*task_msg)->data;
		container->count = 0;
	}

	mpf_message = &container->messages[container->count];
	container->count++;
	return mpf_message;
}
Exemplo n.º 14
0
/** Callback is called from MRCP client stack (task) context.
 *  Signal app_message to the main consumer task of the demo framework
 *  for further processing (see demo_framework_msg_process).
 */
static apt_bool_t demo_framework_message_handler(const mrcp_app_message_t *app_message)
{
	demo_application_t *demo_application;
	if(!app_message->application) {
		return FALSE;
	}
	demo_application = mrcp_application_object_get(app_message->application);
	if(demo_application && demo_application->framework) {
		demo_framework_t *framework = demo_application->framework;
		apt_task_t *task = apt_consumer_task_base_get(framework->task);
		apt_task_msg_t *task_msg = apt_task_msg_get(task);
		if(task_msg) {
			framework_task_data_t *framework_task_data = (framework_task_data_t*)task_msg->data;
			task_msg->type = TASK_MSG_USER;
			task_msg->sub_type = DEMO_APPLICATION_MSG_ID;
			framework_task_data = (framework_task_data_t*) task_msg->data;
			framework_task_data->app_message = app_message;
			framework_task_data->demo_application = demo_application;
			apt_task_msg_signal(task,task_msg);
		}
	}
	return TRUE;
}
Exemplo n.º 15
0
static apt_bool_t mpf_engine_msg_process(apt_task_t *task, apt_task_msg_t *msg)
{
	apr_size_t i;
	mpf_engine_t *engine = apt_task_object_get(task);
	apt_task_msg_t *response_msg;
	mpf_message_container_t *response;
	mpf_message_t *mpf_response;
	mpf_context_t *context;
	mpf_termination_t *termination;
	const mpf_message_t *mpf_request;
	const mpf_message_container_t *request = (const mpf_message_container_t*) msg->data;

	response_msg = apt_task_msg_get(engine->task);
	response_msg->type = engine->task_msg_type;
	response = (mpf_message_container_t*) response_msg->data;
	*response = *request;
	for(i=0; i<request->count; i++) {
		mpf_request = &request->messages[i];
		mpf_response = &response->messages[i];

		if(mpf_request->message_type != MPF_MESSAGE_TYPE_REQUEST) {
			apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid MPF Message Type [%d]",mpf_request->message_type);
			continue;
		}

		mpf_response->message_type = MPF_MESSAGE_TYPE_RESPONSE;
		mpf_response->status_code = MPF_STATUS_CODE_SUCCESS;
		context = mpf_request->context;
		termination = mpf_request->termination;
		switch(mpf_request->command_id) {
			case MPF_ADD_TERMINATION:
			{
				termination->media_engine = engine;
				termination->event_handler = mpf_engine_event_raise;
				termination->codec_manager = engine->codec_manager;
				termination->timer_queue = engine->timer_queue;

				mpf_termination_add(termination,mpf_request->descriptor);
				if(mpf_context_termination_add(context,termination) == FALSE) {
					mpf_termination_subtract(termination);
					mpf_response->status_code = MPF_STATUS_CODE_FAILURE;
					break;
				}
				break;
			}
			case MPF_MODIFY_TERMINATION:
			{
				mpf_termination_modify(termination,mpf_request->descriptor);
				break;
			}
			case MPF_SUBTRACT_TERMINATION:
			{
				if(mpf_context_termination_subtract(context,termination) == FALSE) {
					mpf_response->status_code = MPF_STATUS_CODE_FAILURE;
					break;
				}
				mpf_termination_subtract(termination);
				break;
			}
			case MPF_ADD_ASSOCIATION:
			{
				mpf_context_association_add(context,termination,mpf_request->assoc_termination);
				break;
			}
			case MPF_REMOVE_ASSOCIATION:
			{
				mpf_context_association_remove(context,termination,mpf_request->assoc_termination);
				break;
			}
			case MPF_RESET_ASSOCIATIONS:
			{
				mpf_context_associations_reset(context);
				break;
			}
			case MPF_APPLY_TOPOLOGY:
			{
				mpf_context_topology_apply(context);
				break;
			}
			case MPF_DESTROY_TOPOLOGY:
			{
				mpf_context_topology_destroy(context);
				break;
			}
			default:
			{
				mpf_response->status_code = MPF_STATUS_CODE_FAILURE;
			}
		}
	}

	return apt_task_msg_parent_signal(engine->task,response_msg);
}
Exemplo n.º 16
0
/** Start execution of MPF test suite scenario  */
static void mpf_suite_on_start_complete(apt_task_t *task)
{
	mpf_suite_session_t *session;
	apt_task_t *consumer_task;
	mpf_suite_engine_t *suite_engine;
	apt_task_msg_t *msg;
	mpf_message_t *mpf_message;
	apr_pool_t *pool = NULL;

	consumer_task = apt_task_object_get(task);
	suite_engine = apt_task_object_get(consumer_task);

	apt_log(APT_PRIO_INFO,"On MPF Suite Start");
	apr_pool_create(&pool,NULL);
	session = apr_palloc(pool,sizeof(mpf_suite_session_t));
	session->pool = pool;
	session->context = NULL;
	session->termination1 = NULL;
	session->termination2 = NULL;
	session->rtp_mode = TRUE;

	apt_log(APT_PRIO_INFO,"Create MPF Context");
	session->context = mpf_context_create(session,2,pool);

	apt_log(APT_PRIO_INFO,"Create Termination [1]");
	session->termination1 = mpf_termination_create(suite_engine->file_termination_factory,session,session->pool);

	apt_log(APT_PRIO_INFO,"Add Termination [1]");
	msg = apt_task_msg_get(task);
	msg->type = TASK_MSG_USER;
	mpf_message = (mpf_message_t*) msg->data;

	mpf_message->message_type = MPF_MESSAGE_TYPE_REQUEST;
	mpf_message->command_id = MPF_COMMAND_ADD;
	mpf_message->context = session->context;
	mpf_message->termination = session->termination1;
	mpf_message->descriptor = mpf_file_reader_descriptor_create(session);
	apt_task_msg_signal(suite_engine->engine_task,msg);

	apt_log(APT_PRIO_INFO,"Create Termination [2]");
	if(session->rtp_mode == TRUE) {
		session->termination2 = mpf_termination_create(suite_engine->rtp_termination_factory,session,session->pool);
	}
	else {
		session->termination2 = mpf_termination_create(suite_engine->file_termination_factory,session,session->pool);
	}

	apt_log(APT_PRIO_INFO,"Add Termination [2]");
	msg = apt_task_msg_get(task);
	msg->type = TASK_MSG_USER;
	mpf_message = (mpf_message_t*) msg->data;

	mpf_message->message_type = MPF_MESSAGE_TYPE_REQUEST;
	mpf_message->command_id = MPF_COMMAND_ADD;
	mpf_message->context = session->context;
	mpf_message->termination = session->termination2;
	if(session->rtp_mode == TRUE) {
		mpf_message->descriptor = mpf_rtp_local_descriptor_create(session);
	}
	else {
		mpf_message->descriptor = mpf_file_writer_descriptor_create(session);
	}
	apt_task_msg_signal(suite_engine->engine_task,msg);
}
Exemplo n.º 17
0
/** Process task messages  */
static apt_bool_t mpf_suite_msg_process(apt_task_t *task, apt_task_msg_t *msg)
{
	const mpf_message_t *mpf_message = (const mpf_message_t*) msg->data;
	if(mpf_message->message_type == MPF_MESSAGE_TYPE_RESPONSE) {
		apt_log(APT_PRIO_DEBUG,"Process MPF Response");
		if(mpf_message->command_id == MPF_COMMAND_ADD) {
			apt_log(APT_PRIO_DEBUG,"On Add Termination");
			if(mpf_message->termination) {
				mpf_suite_session_t *session;
				session = mpf_termination_object_get(mpf_message->termination);
				if(session->termination2 == mpf_message->termination && session->rtp_mode == TRUE) {
					apt_task_msg_t *msg;
					mpf_message_t *request;
					apt_task_t *consumer_task;
					mpf_suite_engine_t *suite_engine;

					consumer_task = apt_task_object_get(task);
					suite_engine = apt_task_object_get(consumer_task);

					msg = apt_task_msg_get(task);
					msg->type = TASK_MSG_USER;
					request = (mpf_message_t*) msg->data;

					request->message_type = MPF_MESSAGE_TYPE_REQUEST;
					request->command_id = MPF_COMMAND_MODIFY;
					request->context = session->context;
					request->termination = session->termination2;
					request->descriptor = mpf_rtp_remote_descriptor_create(session);
					apt_task_msg_signal(suite_engine->engine_task,msg);
				}
			}
		}
		else if(mpf_message->command_id == MPF_COMMAND_SUBTRACT) {
			apt_log(APT_PRIO_DEBUG,"On Subtract Termination");
			if(mpf_message->termination) {
				mpf_suite_session_t *session;
				session = mpf_termination_object_get(mpf_message->termination);
				if(session->termination1 == mpf_message->termination) {
					session->termination1 = NULL;
				}
				if(session->termination2 == mpf_message->termination) {
					session->termination2 = NULL;
				}
				mpf_termination_destroy(mpf_message->termination);

				if(!session->termination1 && !session->termination2) {
					apt_task_t *consumer_task;
					mpf_suite_engine_t *suite_engine;

					mpf_context_destroy(session->context);
					session->context = NULL;
					apr_pool_destroy(session->pool);

					consumer_task = apt_task_object_get(task);
					suite_engine = apt_task_object_get(consumer_task);

					apr_thread_mutex_lock(suite_engine->wait_object_mutex);
					apr_thread_cond_signal(suite_engine->wait_object);
					apr_thread_mutex_unlock(suite_engine->wait_object_mutex);
				}
			}
		}
	}
	else if(mpf_message->message_type == MPF_MESSAGE_TYPE_EVENT) {
		apt_task_t *consumer_task;
		mpf_suite_engine_t *suite_engine;
		apt_task_msg_t *msg;
		mpf_message_t *request;
		mpf_suite_session_t *session;
		apt_log(APT_PRIO_DEBUG,"Process MPF Event");
		if(mpf_message->termination) {
			session = mpf_termination_object_get(mpf_message->termination);
			if(session->termination1) {
				apt_log(APT_PRIO_INFO,"Subtract Termination [1]");
				msg = apt_task_msg_get(task);
				msg->type = TASK_MSG_USER;
				request = (mpf_message_t*) msg->data;

				request->message_type = MPF_MESSAGE_TYPE_REQUEST;
				request->command_id = MPF_COMMAND_SUBTRACT;
				request->context = session->context;
				request->termination = session->termination1;

				consumer_task = apt_task_object_get(task);
				suite_engine = apt_task_object_get(consumer_task);
				apt_task_msg_signal(suite_engine->engine_task,msg);
			}
			if(session->termination2) {
				apt_log(APT_PRIO_INFO,"Subtract Termination [2]");
				msg = apt_task_msg_get(task);
				msg->type = TASK_MSG_USER;
				request = (mpf_message_t*) msg->data;

				request->message_type = MPF_MESSAGE_TYPE_REQUEST;
				request->command_id = MPF_COMMAND_SUBTRACT;
				request->context = session->context;
				request->termination = session->termination2;

				consumer_task = apt_task_object_get(task);
				suite_engine = apt_task_object_get(consumer_task);
				apt_task_msg_signal(suite_engine->engine_task,msg);
			}
		}
	}

	return TRUE;
}