/** Process MPF response */ static apt_bool_t mpf_suite_response_process(mpf_suite_agent_t *agent, const mpf_message_t *mpf_message) { mpf_task_msg_t *task_msg = NULL; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process MPF Response"); if(mpf_message->command_id == MPF_ADD_TERMINATION) { apt_log(APT_LOG_MARK,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->rtp_termination == mpf_message->termination) { mpf_rtp_stream_descriptor_t *descriptor = NULL; if(session == agent->rx_session) { descriptor = mpf_rtp_rx_remote_descriptor_create(agent,session); } if(session == agent->tx_session) { descriptor = mpf_rtp_tx_remote_descriptor_create(agent,session); } if(descriptor) { mpf_engine_termination_message_add( agent->engine, MPF_MODIFY_TERMINATION,session->context,session->rtp_termination,descriptor, &task_msg); } mpf_engine_assoc_message_add( agent->engine, MPF_ADD_ASSOCIATION,session->context,session->file_termination,session->rtp_termination, &task_msg); mpf_engine_topology_message_add( agent->engine, MPF_APPLY_TOPOLOGY,session->context, &task_msg); } } } else if(mpf_message->command_id == MPF_SUBTRACT_TERMINATION) { apt_log(APT_LOG_MARK,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->file_termination == mpf_message->termination) { session->file_termination = NULL; } else if(session->rtp_termination == mpf_message->termination) { session->rtp_termination = NULL; } mpf_termination_destroy(mpf_message->termination); if(!session->file_termination && !session->rtp_termination) { mpf_suite_session_destroy(agent,session); } } } return mpf_engine_message_send(agent->engine,&task_msg); }
/** Process MPF response */ static apt_bool_t mpf_suite_response_process(mpf_suite_engine_t *suite_engine, const mpf_message_t *mpf_message) { mpf_task_msg_t *task_msg = NULL; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process MPF Response"); if(mpf_message->command_id == MPF_ADD_TERMINATION) { apt_log(APT_LOG_MARK,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) { void *descriptor = mpf_rtp_remote_descriptor_create(session); mpf_engine_termination_message_add( suite_engine->engine, MPF_MODIFY_TERMINATION,session->context,session->termination2,descriptor, &task_msg); } } } else if(mpf_message->command_id == MPF_SUBTRACT_TERMINATION) { apt_log(APT_LOG_MARK,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) { mpf_engine_context_destroy(session->context); session->context = NULL; apr_pool_destroy(session->pool); 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); } } } return mpf_engine_message_send(suite_engine->engine,&task_msg); }
/** 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; }