예제 #1
0
MPF_DECLARE(void) mpf_context_factory_destroy(mpf_context_factory_t *factory)
{
	mpf_context_t *context;
	while(!APR_RING_EMPTY(&factory->head, mpf_context_t, link)) {
		context = APR_RING_FIRST(&factory->head);
		mpf_context_destroy(context);
		APR_RING_REMOVE(context, link);
	}
}
예제 #2
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;
}
예제 #3
0
MPF_DECLARE(apt_bool_t) mpf_engine_context_destroy(mpf_context_t *context)
{
	return mpf_context_destroy(context);
}