Example #1
0
MPF_DECLARE(apt_bool_t) mpf_context_destroy(mpf_context_t *context)
{
	apr_size_t i;
	mpf_termination_t *termination;
	for(i=0; i<context->capacity; i++){
		termination = context->header[i].termination;
		if(termination) {
			mpf_context_termination_subtract(context,termination);
			mpf_termination_subtract(termination);
		}
	}
	return TRUE;
}
Example #2
0
MPF_DECLARE(apt_bool_t) mpf_context_destroy(mpf_context_t *context)
{
    apr_size_t i;
    apr_size_t count = context->max_termination_count;
    mpf_termination_t *termination;
    for(i=0; i<count; i++) {
        termination = context->table[i][i];
        if(termination) {
            mpf_context_termination_subtract(context,termination);
            if(termination->audio_stream) {
                mpf_audio_stream_destroy(termination->audio_stream);
            }
        }
    }
    return TRUE;
}
Example #3
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);
}